Email validation scheme tells that how to check if a user's email address is valid.
Email validation checks the following points Figure 2: Above two figures are example of valid and invalid emails.
So in the above example, if the input contained an @ when the pattern does not include an @ the test would return false and the validation would fail.
To create a validation for your name field, type the following line into your and assign it the regex of any capital letter (A-Z), any lower case letter (a-z), a space, a hyphen or an apostrophe.
Figure 1: Above figure is output of validation of empty field In above script, function Empty will check that the HTML input that is being send to the server has something in it.
This alerts the user to any errors and allows her to correct her errors before proceeding and losing her progress.
In order to create a set of rules we use a Regular Expression (Regex).
The next step is to prevent the form from being submitted if any of the validation rules are broken.
This is handy because we don’t really want to allow our user to submit a form with invalid data.Once the form is validated on the server side, it should spit it back out with an error message.