Validating a form using javascript

12 Feb

You can then adapt this form to your own requirements.Let's build a simple form with a validation script.As an exercise, try modifying the script to only prompt the user one field at a time.For example, if they miss out the "Name" and "Gender" fields and press "Send Details", it will only prompt them for the "Name" field initially.

Let's look at a more complex validated form with some different types of form fields. Try pressing the Send Details button without filling in the form and see what happens.One point to note about Java Script validation is that it can always be circumvented by the user disabling Java Script in their browser, so for secure validation you'll need to write your validating code in your server-side scripts.However, for day-to-day use Java Script is a quick and easy way to check over your forms before they're sent to your server.Form validation is the process of checking that a form has been filled in correctly before it is processed.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.