Make your own free website on

Checking Input Values

The following JavaScript function takes 3 parameters. If the value parameter falls outside the range of the min and max values an alert dialog is displayed to that affect.

The above function can be used to check a input field on a form as shown below.

Test the above in an HTML form.

Handling the events inline

You could have handled the value checking inline as shown below:

This would work, but not be as flexible as using a function. Also if the program is long, it can be far more error prone to do it this way. It also detracts from the understandability of the form source code.