-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
jQuery 2.0 Development Cookbook
By :
E-mail address validation is one of the most common types of validation on the Web. Most people would believe that a valid e-mail address only contains alphanumeric characters with the exception of the @ symbol and a full stop. While most e-mail addresses are typically of this format, a valid e-mail address can actually contain a variety of other characters. This recipe will show you how to add e-mail validation to the web form we have been using in the last four recipes.
Create e-mail validation that can be reused again and again by performing the following instructions:
Add the additional hasClass check and if statement to the main for loop in validation.js as follows:
if ($(input).hasClass('email') && !validateEmail($($(input)).val())) {
addErrorData($(input), "Invalid email address provided");
isError = true;
}Add the following validateEmail() function to the end of validation.js:
function validateEmail(value) {
if (value !=...
Change the font size
Change margin width
Change background colour