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: .
You should always validate form data on the server-side even if they are already validated on the client-side, because user can disable Java Script in their browser.
which is performed to ensure that the type and format of the data entered in the form is valid.
The idea is to create a set of “validation descriptors” associated with each element in a form.