The JavaScript code is freely available for download on code.google.com/p/javascriptformvalidation/
Home | Download | Demo | Instructions | Why use JavaScript Form Field Validation? | How can you help? | Members
The following demonstrates how you validate a form field and process the error with a custom error handler.
See the form validation demo on its own
The code below can be copied and pasted on your own page for testing and should work as is.
Please note that we have limited the demo to two form fields to keep it readable.
Note that the Property object gets passed in a reference to a custom error handler.
This error handler receives a reference to the Property object itself which allows us to work with the information in the form field.
On line 2 the custom error handler expects an HTML element with id "businessNameContainerMessage" to be present, where "businessName" is the name that matches the form field and the same goes for "businessNameContainerMessage" on line 3.
On line 4 the error message gets inserted in the message container, and on line 5 the CSS class is changed so that the style of the error area changes.
Comments are moderated
Sponsored by clickfind - Advertise your Business online