Validating the form input

Here we demonstrate three methods for interacting with the user during the form validation (check Controlling form submission for more details).

In the following example if the user would select the option "other" a prompt will appear asking to specify the city.
Alerts just give a warning to the user. They can also be used for debugging your scrips.
Confirm returns a boolean value (true/false) depending on the button clicked.

In many cases parseInt() method can be used to validate the numeric values of the fields.


1.Select your city:
 If other (specify):
2.Enter your age:
3. Format your hard drive?