If the user has not completed more than one field, then they will see an alert box appear for each field that is missing.
Now you know how to write a form validation script that can handle multiple form fields, including text boxes, radio buttons, drop-down lists and check boxes!
This tutorial will show you how to create a Java Script-enabled form that checks whether a user has filled in the form correctly before it's sent to the server. First we'll explain why form validation is a useful thing, and then build up a simple example form, explaining things as we go along.
At the end, there's a little exercise to keep you busy too!
We want to the user to agree to our imaginary Terms and Conditions before they send the form, so we'll check to make sure they've clicked the checkbox: in any one of the above cases, if one or more of our checks fail, the form will not be sent to the server.
Shows you how to write a script that ensures your form is filled in correctly before it's sent to your server.
Great for "required fields" such as email addresses!
Our example is very simple as it only checks one field.
Let's expand this example with a more complex function that checks lots of form fields.
This is the best book on the subject I’ve ever read, showing you step-by-step the smartest ways to create usable, useful DHTML effects to enhance your site.