Jsp code for validating email address
Jsp code for validating email address - good lines for dating sites
At the end, there's a little exercise to keep you busy too!Form validation is the process of checking that a form has been filled in correctly before it is processed.
There are two main methods for validating forms: (usually done using Java Script).This was really a lengthy process which used to put a lot of burden on the server.Java Script provides a way to validate form's data on the client's computer before sending it to the web server. First let us see how to do a basic form validation.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.An email address must contain at least a ‘@’ sign and a dot (.).
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.
This Java Script demo verifies that an email address is in the correct format and that the user has typed in the same address in both fields to prevent mistyping of the address.
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.
Form validation normally used to occur at the server, after the client had entered all the necessary data and then pressed the Submit button.
If the data entered by a client was incorrect or was simply missing, the server would have to send all the data back to the client and request that the form be resubmitted with correct information.
Let's build a simple form with a validation script.