I'm trying to build a sign-up form that will only accept .EDU e-mail addresses. I also want to keep the AJAX functionality I have (using the "remote" parameter) to ensure that the e-mail address hasn't been used before.
How can I do this?
I'm trying to build a sign-up form that will only accept .EDU e-mail addresses. I also want to keep the AJAX functionality I have (using the "remote" parameter) to ensure that the e-mail address hasn't been used before.
How can I do this?
$.validator.addMethod("edu-email",
function(value) {
return (value.endsWith(".edu"));
},
"e-mail address must end in .edu."
);
JavaScript doesn't have a string.endsWith. You'll have to add your own.
Now add "edu-email" to the form input class.