my code: http://jsfiddle.net/umSFC/
i follow How to validate email in Jquery? for email validation but seem dont work on mine?
my code: http://jsfiddle.net/umSFC/
i follow How to validate email in Jquery? for email validation but seem dont work on mine?
Use jQuery Validate plugin. Has an email validator for what you want and is better to use a consistent validation throughout your application and forms. On other hand is better to use tested components and whenever possible use existing works and not reinvent the wheel.
Here i have fixed your exsample
$(document).ready(function() {
$("#submit").click(function(e) {
var name = $("#name");
var email = $("#email");
var emailaddressVal = $("#email").val();
var emailReg = /^[A-Z0-9._%+-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i;
if (name.val() == "") {
name.addClass("error").focus();
return false;
} else {
name.removeClass("error");
}
if (!emailReg.test(email.val())) {
email.addClass("error").focus();
} else {
email.removeClass("error");
}
e.preventDefault();
});
});