Simply, quickly and effectively use j Query to validate and verify email addresses.
Stop bad email addresses before they get into your system. Let's face it, validating, verifying and checking input data is not what is generally described as a "fun" activity if you're a web developer.
The if block in lines 3-6 checks to see if the email address in the first field passes the regex check by invoking the search() method on our email string value.
This method accepts regex expressions as arguments to check the string and returns the position of the specified value in the string or a -1 if no match was found.
Nothing exciting here except in line 6 where the on Click event is triggered when the user clicks on the button.Here are some simple steps to make the process more secure.If the purpose of registration is to confirm that the person exists, and that they have supplied a valid email address, then as part of the registration processe you a should either email them a random password or a confirmation token rather than letting them choose their own password and use it immediately.If the email addresses passes both these tests, then the function will return a true value.The regex for validating the correct email format in line 2 has been borrowed and edited slightly by adding the i flag so that the regex is case-insensitive.