Basic Validation: To make sure data is entered into each form field that required it.
Data Format Validation: To check that data entered is correct or not. It checks the correct form and value.
• Required fields
• Valid user name
• Valid password
• Valid e-mail address
• Valid phone number
1. Required Fields:
2. Valid User Name:
It is data format validation in which the function checks
• If the username field contains anything at all entered by the user.
• If the username field is not blank, the function checks the length of the string and permit only usernames that is between 5 and 15 characters.
3. Valid Password:
* This one /[\W_]/ allow only letters and numbers.
* seacrh() method and two more regular expressions: /(a-z)+/ and /(0-9)/ allows only passwords that contain letters and at least one numeral.
4. Valid e-mail address:
* The data entered for email address must contain at least an @ sign and a dot (.) for which the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign.
* At first we check if the user entered anything at all in the email field. Next, we use regular expression and the test() method to check the field for a compliance. Also we will use trim() function that will trim leading whitespace off the string. This won’t be perfect validation — it is possible to slip not compliant addresses by it — but it's normally good enough.
5. Valid Phone Number:
* Firstly we use regular expression and the replace () method to clear out any spacer characters.
* Then the isNaN() function is used to check if the phone number contain only numbers.
* And finally the function checks the length of the string and allows only phone numbers with 10 digits.