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.
If the search() method returns a -1, then an alert would tell the user that an invalid email address has been entered and returns a false value.
Lines 7-10 checks to see if the user has entered the same string in both email fields.
This is done by a simple equality check on the string values.
Nothing exciting here except in line 6 where the on Click event is triggered when the user clicks on the button.
This event will launch the verify Email() Java Script function which will check the user input of the email address.
Here is the code for the verify Email() function: This function will return a false value if the user does not type in an email address in the correct format or if the user fails to type in the same email address in both fields.
If the strings are different, an alert warns the user that the email addresses are not the same and returns a false value.If we have passed the two tests, then else block in lines 11-14 gets executed.