I’m trying to create a rule that checks is the email host is Hotmail so I can show a message asking to check their spam folder (most of my messages go to that folder when people use Hotmail).
Here’s what I’ve done so far:
jQuery.validator.addMethod("isHotmail", function(value, element) {
var email = $("#email").val();
var emailHost = email.split('@')[1].split('.')[0];
if(emailHost=='hotmail'){return true}
}, "* you are using Hotmail, please check your spam folder");
And
rules: {
email: {
required:true, email: true, isHotmail : true
}
.
.
This is not working, nothing happens if I enter a Hotmail email address, and I suspect that it is because of the return statement.
Can anyone please give me a hand with this rule?
Thanks a lot
You need to return false when the input contains ‘hotmail’. So instead of
use
See it in action on jsfiddle here