|
Package /org/apache/commons/validator/javascript | |||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||
No overview generated for 'validateMaxLength.js'
| Method Summary | |
static Object
|
validateMaxLength(form)
A field is considered valid if less than the specified maximum. |
/*$RCSfile: validateMaxLength.js,v $ $Rev: 232626 $ $Date: 2005-08-14 18:45:34 +0100 (Sun, 14 Aug 2005) $ */
/**
* A field is considered valid if less than the specified maximum.
* Fields are not checked if they are disabled.
* <p>
* <strong>Caution:</strong> Using <code>validateMaxLength</code> on a password field in a
* login page gives unnecessary information away to hackers. While it only slightly
* weakens security, we suggest using it only when modifying a password.</p>
* @param form The form validation is taking place on.
*/
function validateMaxLength(form) {
var isValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oMaxLength = eval('new ' + retrieveFormName(form) + '_maxlength()');
for (x in oMaxLength) {
var field = form[oMaxLength[x][0]];
if ((field.type == 'hidden' ||
field.type == 'text' ||
field.type == 'password' ||
field.type == 'textarea') &&
field.disabled == false) {
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;
}
|
Package /org/apache/commons/validator/javascript | |||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||