Validating fields using javascript

validate Email ( ) Next we want to see if the email address the user entered is real.This means that the input data must contain at least an @ sign and a dot (.).If its not blank, we check the length of the string and permit only usernames that are between 5 and 15 characters.Next, we use the Java Script regular expression /\W/ to forbid illegal characters from appearing in usernames.We want to allow only letters, numbers and underscopes.

validate Phone ( ) The function below checks if the phone number is valid.At last we check the length of the string and permit only phone numbers with 10 digits. When the user clicks the Submit button on the form, the form data is sent to a Java Script validation function that checks each field to make sure that it is in the appropriate format.provides a declarative way of validating javascript objects.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.