Home » News » Easy Form Validation with Java ...

News by JavaScriptSearch


Easy Form Validation with JavaScript

 

JavaScriptSearch
Wednesday, May 10, 2006; 02:04 AM

Web developer Andrew Tetlaw has posted online a robust JavaScript form validation method.  Instructions and live demo are available at http://tetlaw.id.au/view/blog/really-easy-field-validation-with-prototype/ .

Form validation allows for the creation of forms, that auto-check for incorrect user input.

 

This particular form validation approach needs the Prototype library ( http://prototype.conio.net/).  The basic method is to attach to the form's onsubmit event, read out all the form elements' classes and perform validation if required. If a field fails validation, advice appears and the form is prevented from submitting.

The validator also avoids validating fields that are hidden or children of elements hidden by the CSS property display:none. This way you can give a field the class of 'required' but it's only validated if it is visible on the form.

Advertisement

Partners

Related Resources

Other Resources

arrow