A small but powerful unobtrusive form validation script that uses regular expressions to validate input field and textarea values.
At a glance:
- Unobtrusive javascript
- Validates multiple forms per page
- Multiple validations possible for each form field
- Leverages the power of Regular Expressions
- Validation rules are stipulated within harmless HTML comments, removing the need for adding invalid attributes to the DOM or extra in-line classnames to the form fields themselves (Caveat: it does mean therefore that comments are added to the HTML markup)
- Both input fields and their associated labels targeted, giving the developer two opportunities to visually indicate erroneous input to the user
- Both warnings and errors thrown warnings before the submit button has been pressed and errors after
- The object prototype can be easily extended to validate other types of form fields (checkboxs, radio buttons etc) or carry out additional validation checks etc
- Fields can be validated
onchange or onblur
- Works with both implicit and explicit labels
View the javascript source.
View page source to see the commented validation parameters.