At first we use regular expression and the replace() method to clear out any spacer characters.Next, we use the is Na N() function to check if the phone number contain only numbers.
This means that the input data must contain at least an @ sign and a dot (.).
The idea behind Java Script form validation is to provide a method to check the user entered information before they can even submit it.
Java Script also lets you display helpful alerts to inform the user what information they have entered incorrectly and how they can fix it.
We want to allow only letters, numbers and underscopes.
validate Password ( ) The function below checks the password field for blankness and allow only letters and numbers - no underscopes this time.
So we should use a new regular expression to forbid underscopes. Next, we want to permit only passwords that contain letters and at least one numeral.
For that we use the seacrh() method and two more regular expressions: /(a-z) / and /(0-9)/.
If the element complies than sufunction returns an empty string.
Otherwise it returns a message describing the error and highlight appropriate element with yellow.
If you run a validation of the users form input before the form is submitted, there will be no wait time and redundant load on the server.
This wont be perfect validation it is possible to slip not compliant addresses by it but it's normally good enough.