Java script validating form
Once you have an HTML form up and running, you will often want to make sure that all the important fields are filled in.
For example, if you are going to send an email confirmation letter, the email address should be included in the form fields, and it should be an email address that works.
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.
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 (.).
Otherwise it returns a message describing the error and highlight appropriate element with yellow.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.Java Script is an object-oriented, interpretive language used with HTML to provide dynamic capabilities to otherwise static webpages.
A Java Script function included in an HTML page is processed and executed by the web browser.Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign.