Return to Snippet

Revision: 23931
at February 19, 2010 15:58 by vagrantradio


Updated Code
$(function(){
 
var email = $("input#email").val();
	if(isValidEmailAddress(email)) {
		$(email).after("hooray!");
	} else {
		$(email).addClass("yourerror").after("<label class='error'>Email is not valid!</label>").focus();
		return false;
	}
});
 
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

Revision: 23930
at February 16, 2010 16:05 by vagrantradio


Initial Code
$(function(){
 
var email = $("input#email").val();
	if(isValidEmailAddress(email)) {
		$("input#email").after("hooray!");
	} else {
		$("input#email").addClass("yourerror").focus();
		$("input#email").after("<label class='error'>Email is not valid!</label>");
		return false;
	}
});
 
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

Initial URL

                                

Initial Description

                                

Initial Title
CHECK VALID EMAIL ADDRESS JQUERY

Initial Tags
regex, email

Initial Language
jQuery