Form validation is a crucial thing in web applications and making them sometimes requires hard work. Here’s a form validation script that is very easy to use. It has a number of tests built-in but is extensible to include your custom validation checks. Here’s the list of tests available to add to your field elements:
-
not blank – required
-
a valid number
-
digits only
-
letters only
-
only letters and numbers
-
a valid date value
-
a valid email address
-
a valid URL
-
a date formatted as; dd/mm/yyyy
-
a valid dollar value
-
first option e.g. ‘Select one…’ is not selected option
-
At least one textbox/radio element must be selected in a group
Here is a demo of the field validation.