It is one of the most effective techniques for validating the user inputs.
Furthermore, the above script will also display the data entered by the user in an alert dialog box for preview purpose before submitting the form to the web server.
Note: Client-side validation is not a substitute or alternative for server-side validation.
Each field in the form can have zero one or more validations. More info & downloads where Do My Validation One() and Do My Validation Two() are custom functions for validation.
For example, you can have an input field that should not be empty, should be less than 25 chars and should be alpha-numeric. In some dynamically programmed pages, it may be required to change the validations in the form at run time.
Using client side Java Script is an efficient way to validate the user input in web forms.
When there are many fields in the form, the Java Script validation becomes too complex.