But it is quite possible that some user might not enter the data what you've expected.So to save bandwidth and avoid unnecessary strain on your server resources you can validate the form data on client-side (i.e.Well, let's create a Java Script file named "validator.js" and place the following code inside it, then save it at the same location where you've saved the previous HTML file.Go through each line of the following example code to understand how Java Script validation works: .Form validation normally used to occur at the server, after the client had entered all the necessary data and then pressed the Submit button.If the data entered by a client was incorrect or was simply missing, the server would have to send all the data back to the client and request that the form be resubmitted with correct information.But, to get the values from a form field that supports multiple selections, like a group of checkboxes, you need to utilize the loop statement as shown in the example above (line no-14 to 21).
Also, the ‘@’ must not be the first character of the email address, and the last dot must at least be one character after the ‘@’ sign.
Now we will see how we can validate our entered form data before submitting it to the web server.
The following example shows how to validate an entered email address.
Web forms have become an essential part of web applications.
It is often used to collect user's information such as name, email address, location, age, and so on.