This script defines a number of functions that allow common form data validations to be performed. Among them are:
Other functions also strip spaces or illegal keyboard characters from form data.
( Javascript 1.1 | JScript 2.0 | ECMAScript 1.0 ) & DOM 0
Posted.
Added trimWhitespace() function.
Added the ability to check for the validity of individual credit card types to isValidCreditCard().
Added a stricter email address check (the original test is still available).
Added a generic form validation function and support for 9 digit zipcodes.
Added fix for IE bug where dropdowns have a non-standard identifier.
Added phone number validation.
Added a check for <select> options with an empty value to the generic form validation function.
Bug fix for yesterday's addition.
Changed email validation to use a Regex; fixed radio button checking (thanks Steve).
Fixed phone number check (thanks Mark).
Fixed multiple radio group validation and repeated validation (thanks W Dean).
Better radio group validation and fixed example page for same (thanks Vincent).
This script is released under a Creative Commons License.