我试图建立一个注册表单,将只接受.EDU电子邮件地址。 我也想保持AJAX功能我有(使用远程参数) 以确保该电子邮件地址没有被使用过。
我怎样才能做到这一点?
解决方案 $。validator.addMethod(EDU-电子邮件,
函数(值){
返回(value.endsWith()EDU。);
},
E-mail地址必须结束在埃杜。
);
JavaScript没有一个string.endsWith。你必须添加自己的。
现在加入EDU-邮件的形式输入类。
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.