You might like to open the source code for this form in a separate window, so that you can refer to it throughout the tutorial. This means that we can prevent the form from being sent if the user hasn't filled it in properly.
You can see that the page consists of a Java Script function called method to send the data off to a dummy CGI script on ELATED.com's server that thanks the user. The rest of the form prompts the user to enter their name into a form field called That's all there is to simple Java Script form validation!
For example, if your form has a box for the user to type their email address, you might want your form handler to check that they've filled in their address before you deal with the rest of the form.
In reality, you would of course send the data to your own CGI script, ASP page, etc. Our example is very simple as it only checks one field.
The form will include one text field called "Your Name", and a button.
Our validation script will ensure that the user enters their name before the form is sent to the server. Try pressing the Send Details button without filling anything in the "Your Name" field.
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!