While input validation should always be performed server-side, it’s very helpful to users to perform basic client-side validation using JavaScript.
We use the small, but still very flexible Validate.js library. Below are working examples of basic validation techniques for commonly-used form field types.
More Information in the WCAG 2.0 Guidelines
SCR18: Providing client-side validation and alert
SCR32: Providing client-side validation and adding error text via the DOM
Use HTML 5 Input Types
When you use the appropriate input type
on an input, modern browsers will do basic client-side validation (and older browsers will handle it just fine). Modern browsers will also provide useful controls for users.