commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rlel...@apache.org
Subject cvs commit: jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript validateMinLength.js validateMaxLength.js validateIntRange.js validateFloatRange.js
Date Sun, 18 May 2003 21:35:37 GMT
rleland     2003/05/18 14:35:37

  Added:       validator/src/javascript/org/apache/commons/validator/javascript
                        validateMinLength.js validateMaxLength.js
                        validateIntRange.js validateFloatRange.js
  Log:
  Add Javascript validations for Min/Max Length
  & Int & Float Range
  
  Revision  Changes    Path
  1.1                  jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript/validateMinLength.js
  
  Index: validateMinLength.js
  ===================================================================
  
      function validateMinLength(form) {
          var isValid = true;
          var focusField = null;
          var i = 0;
          var fields = new Array();
          oMinLength = new minlength();
          for (x in oMinLength) {
              var field = form[oMinLength[x][0]];
  
              if (field.type == 'text' ||
                  field.type == 'textarea') {
  
                  var iMin = parseInt(oMinLength[x][2]("minlength"));
                  if ((field.value.length > 0) && (field.value.length < iMin))
{
                      if (i == 0) {
                          focusField = field;
                      }
                      fields[i++] = oMinLength[x][1];
                      isValid = false;
                  }
              }
          }
          if (fields.length > 0) {
             focusField.focus();
             alert(fields.join('\n'));
          }
          return isValid;
      }
  
  
  1.1                  jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript/validateMaxLength.js
  
  Index: validateMaxLength.js
  ===================================================================
  
      function validateMaxLength(form) {
          var isValid = true;
          var focusField = null;
          var i = 0;
          var fields = new Array();
          oMaxLength = new maxlength();
          for (x in oMaxLength) {
              var field = form[oMaxLength[x][0]];
  
              if (field.type == 'text' ||
                  field.type == 'textarea') {
  
                  var iMax = parseInt(oMaxLength[x][2]("maxlength"));
                  if (field.value.length > iMax) {
                      if (i == 0) {
                          focusField = field;
                      }
                      fields[i++] = oMaxLength[x][1];
                      isValid = false;
                  }
              }
          }
          if (fields.length > 0) {
             focusField.focus();
             alert(fields.join('\n'));
          }
          return isValid;
      }
  
  
  1.1                  jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript/validateIntRange.js
  
  Index: validateIntRange.js
  ===================================================================
  
      function validateIntRange(form) {
          var isValid = true;
          var focusField = null;
          var i = 0;
          var fields = new Array();
          oRange = new intRange();
          for (x in oRange) {
              var field = form[oRange[x][0]];
              
              if ((field.type == 'text' || field.type == 'textarea') &&
                  (field.value.length > 0)) {
  
                  var iMin = parseInt(oRange[x][2]("min"));
                  var iMax = parseInt(oRange[x][2]("max"));
                  var iValue = parseInt(field.value);
                  if (!(iValue >= iMin && iValue <= iMax)) {
                      if (i == 0) {
                          focusField = field;
                      }
                      fields[i++] = oRange[x][1];
                      isValid = false;
                  }
              }
          }
          if (fields.length > 0) {
              focusField.focus();
              alert(fields.join('\n'));
          }
          return isValid;
      }
  
  
  1.1                  jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript/validateFloatRange.js
  
  Index: validateFloatRange.js
  ===================================================================
  
      function validateFloatRange(form) {
          var isValid = true;
          var focusField = null;
          var i = 0;
          var fields = new Array();
          oRange = new floatRange();
          for (x in oRange) {
              var field = form[oRange[x][0]];
              
              if ((field.type == 'text' ||
           field.type == 'textarea') &&
          (field.value.length > 0)) {
          
          var fMin = parseFloat(oRange[x][2]("min"));
          var fMax = parseFloat(oRange[x][2]("max"));
          var fValue = parseFloat(field.value);
          if (!(fValue >= fMin && fValue <= fMax)) {
              if (i == 0) {
                  focusField = field;
              }
              fields[i++] = oRange[x][1];
              isValid = false;
          }
              }
          }
          if (fields.length > 0) {
              focusField.focus();
              alert(fields.join('\n'));
          }
          return isValid;
      }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message