I have borrowed the regex for verifying the correct email format from a different site. Please note that I have removed the action attribute because this is only a demo and we are only concerned with the client-side verification of the Java Script function.Nothing exciting here except in line 6 where the on Click event is triggered when the user clicks on the button.If the email addresses passes both these tests, then the function will return a true value.
If not, the form submition is canceled, and the surfer prompted to re-enter a valid address.
The script makes the following assumptions regarding what a valid email address is: -Contains a least one character procedding the "@" -Contains a "@" following the procedding character(s) -Contains at least one character following the "@", followed by a dot (.), followed by either a two character or three character string (a two character country code or the standard three character US code, such as com, edu etc) Note that this script requires NS 4 or IE 4 to function- all other browsers will simply not participate in the form validation process.
There are no required external dependencies at all!
Though for the datetime and date validator to you need to specify a parse and format function and for that you most likely will want to use a library, is highly recommended.
We are developers, we are technical folk, so it’s no surprise that the prevailing wisdom is to check that it matches the official criteria, some examples of the diversity of the official criteria are…If you have a well laid-out form with a label that says “email”, and the user enters an ‘@’ symbol somewhere, then it’s safe to say they understood that they were supposed to be entering an email address. Next, we want to do some validation to ascertain if they correctly entered right?