2
/*$RCSfile: validateMaxLength.js,v $ $Revision: 1.10 $ $Date: 2004/03/28 16:53:21 $ */
4
* A field is considered valid if less than the specified maximum.
5
* Fields are not checked if they are disabled.
7
* <strong>Caution:</strong> Using <code>validateMaxLength</code> on a password field in a
8
* login page gives unnecessary information away to hackers. While it only slightly
9
* weakens security, we suggest using it only when modifying a password.</p>
10
* @param form The form validation is taking place on.
12
function validateMaxLength(form) {
14
var focusField = null;
16
var fields = new Array();
17
var formName = form.getAttributeNode("name");
19
oMaxLength = eval('new ' + formName.value + '_maxlength()');
20
for (x in oMaxLength) {
21
var field = form[oMaxLength[x][0]];
23
if ((field.type == 'hidden' ||
24
field.type == 'text' ||
25
field.type == 'password' ||
26
field.type == 'textarea') &&
27
field.disabled == false) {
29
var iMax = parseInt(oMaxLength[x][2]("maxlength"));
30
if (field.value.length > iMax) {
34
fields[i++] = oMaxLength[x][1];
39
if (fields.length > 0) {
41
alert(fields.join('\n'));
b'\\ No newline at end of file'