Our example script works by validating all the form fields at once.
This can be a bit confusing for the user, especially if they've missed out more than one field, as they will get lots of alert boxes appearing and they might forget which fields they need to fill in!
We'll also look at how to check other types of fields, such as checkboxes, radio buttons and drop-down lists.
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.
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.
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.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.You can then adapt this form to your own requirements.Let's build a simple form with a validation script.