1. Computing & Technology

Validate Form Content

You can validate what your visitors enter into fields on your form both when they enter the field itself and immediately before they submit the form. These tutorials will show you how.
  1. Validating Forms Using Event Handlers (6)
  2. Complete Scripts (3)
  3. Text Field Validation (9)
  4. Yet More Validations (6)

JavaScript Form Processing

Changes to both JavaScript and HTML have affected the way we should be using JavaScript to validate our forms and will affect it further in the future.

Attaching Validation To A Form

The modern unobtrusive way of attaching JavaScript to validate a form in your web page doesn't require any changes to the HTML of the form.

Individual Field Validations

When we set up unobtrusive form field validation we can easily share validation between fields that need to validate the same way.

Unobtrusive Error Handling

Once our form validation detects an error we need an unobtrusive way to display the error.

Required Fields

Even though older browsers don't support the HTML5 required attribute for form fields we can implement it ourselves in JavaScript.

Pattern Matching

Even though older browsers don't support the HTML5 pattern attribute for form fields we can implement it ourselves in JavaScript.

JavaScript Form Processing - A Complete Example

Incorporating all of the above code in the one example to show you how all of the unobtrusive form processing interacts in performing actual field validations.

©2012 About.com. All rights reserved.

A part of The New York Times Company.