exists(???options???)) params.get(???options???) else ??????;
var pattern = if(params.exists(???pattern???)) params.get(???pattern???) else ??????;
var re = new EReg(pattern, opt);
if(re.match(value))
return isValid();
else
return isInvalid(if(params.exists(???message???))
params.get(???message???)
else
???Field doesn??™t match the pattern???);
}
}
The FormValidator does different things. First, it wires the two events of the form onsubmit and
onreset . The first triggers a global validation action preventing the submission if at least an error has
occurred; the second, whose purpose is to restore the form to its initial state, adds a cleanup function that
removes any error message currently visible. Then the constructor traverses every input control in the
form and looks for the presence of a validation attribute. If the attribute exists, it is parsed and
interpreted; a new rule is created and stored along with a reference to the control. Each control is also
enhanced with an onblur handler that is executed each time the user moves the focus from the current
control to another.
Pages:
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777