/[drupal]/contributions/modules/jsv/js/validator.js
ViewVC logotype

Diff of /contributions/modules/jsv/js/validator.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Thu Sep 6 20:38:25 2007 UTC revision 1.2, Thu Oct 4 18:02:10 2007 UTC
# Line 6  var validator = function() { Line 6  var validator = function() {
6      return {      return {
7          orientationValid : 'before',          orientationValid : 'before',
8          orientationError : 'before',          orientationError : 'before',
         valid            : '',  
9          validMessages    : true,          validMessages    : true,
10          errorNumeric     : 'Numbers only.',          errorNumeric     : 'Numbers only.',
11          errorEmail       : 'Invalid email.',          errorEmail       : 'Invalid email.',
# Line 15  var validator = function() { Line 14  var validator = function() {
14          * Initialize          * Initialize
15          */          */
16          init : function() {          init : function() {
17              // settings
18              var settings = Drupal.settings.jsv;
19    
20              $.each(settings, function(i, e){
21                validator[i] = e;
22              });
23              // event handlers
24            $('.numeric').change(function(){ validator.numeric(this); });            $('.numeric').change(function(){ validator.numeric(this); });
25            $('.email').change(function(){ validator.email(this); });            $('.email').change(function(){ validator.email(this); });
26            $('.request').change(function(){ validator.request(this); });            $('.request').change(function(){ validator.request(this); });
# Line 23  var validator = function() { Line 29  var validator = function() {
29          /**          /**
30          * Display a valid message          * Display a valid message
31          */          */
32          validDisplay : function(input) {          validDisplay : function(input, message) {
33            // remove previous messages            // remove previous messages
34            validator.validRemove(input);            validator.validRemove(input);
35            validator.errorRemove(input);            validator.errorRemove(input);
36            if (validator.validMessages == true){            if (validator.validMessages == true && typeof message != 'undefined'){
37              // add messages              // add messages
38              switch(validator.orientationValid){              switch(validator.orientationValid){
39                case 'before':                case 'before':
40                  $(input).before('<span class="validator-valid">' + validator.valid + '</span>');                  $(input).before('<span class="validator-valid">' + message + '</span>');
41                  break;                  break;
42    
43                case 'after':                case 'after':
44                  $(input).after('<span class="validator-valid">' + validator.valid + '</span>');                  $(input).after('<span class="validator-valid">' + message + '</span>');
45                  break;                  break;
46              }              }
             $(input).addClass('validator-valid-input');  
47            }            }
48              $(input).addClass('validator-valid-input');
49          },          },
50    
51          /**          /**
# Line 167  var validator = function() { Line 173  var validator = function() {
173            if (validatorPath){            if (validatorPath){
174              $.getJSON(validatorPath + '/' + value, function(json){              $.getJSON(validatorPath + '/' + value, function(json){
175                if (json.valid){                if (json.valid){
176                  validator.validDisplay(input);                  validator.validDisplay(input, json.message);
177                }                }
178                else{                else{
179                  validator.errorDisplay(input, json.message);                  validator.errorDisplay(input, json.message);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2