jQuery Validate,需要阻止免费的电子邮件地址(例如Gmail,Hotmail) [英] jQuery Validate, need to prevent free email addresses (e.g. Gmail, Hotmail)

查看:95
本文介绍了jQuery Validate,需要阻止免费的电子邮件地址(例如Gmail,Hotmail)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要添加一个自定义验证规则(或规则集),以防止注册整个电子邮件地址列表.这已经在服务器端运行了,但是我们也希望前端也能做到这一点.

I need to add a custom validation rule (or set of rules) to prevent a whole list of email addresses from registering. This is already running server side, but we want to have the front-end mimic this as well.

我有40个或50个免费电子邮件帐户(例如Gmail,Hotmail,Live Mail等),需要使用列表中的一个词干将任何电子邮件地址验证为FALSE.

I have a large array of 40 or 50 free email accounts (e.g. Gmail, Hotmail, Live mail, etc) and need to have any email addresses using one of the stems from the list validate as FALSE.

我该怎么做?

推荐答案

如果您已经具有正在运行的服务器端,只需向服务器发出AJAX请求即可重用相同的验证逻辑. (您的客户端代码将向服务器发送XMLHttpRequest,服务器的验证逻辑运行,并将状态返回给客户端-所有这些都不需要重新加载HTML页面.您已经表明您正在使用jQuery,因此应该很容易.)

If you already have this running server-side, just make an AJAX request back to your server to reuse the same validation logic. (Your client code will make a XMLHttpRequest back to the server, the server's validation logic runs, and returns the status to the client - all without requiring the HTML page to reload. You've already indicated that you're using jQuery, so this should be easy.)

作为一项额外的奖励,您的服务器端代码可以缓存支票-这样,当服务器重复进行支票检查(可能仅在几秒钟后)进行验证时,无需涉及客户端(对于安全性是必需的,因为由服务器发送的任何信息)客户无法信任-例如Firebug等)-服务器可能不需要重复检查的全部工作. (这可能太琐碎而无法优化,而又不确切知道服务器端验证包含的内容.如果它包括对Web服务的任何外部调用等,则可能值得缓存.)

As an added bonus, your server-side code could cache the check - so that when the server repeats the check (probably only a few seconds later) for verification without client-involvement (necessary for security, as anything sent by the client can't be trusted - think Firebug, etc.) - the server may not need to repeat the full work of its check. (This may be too trivial to optimize, without knowing exactly what your server-side validation includes. If it includes any external calls to web services, etc., it is probably worth caching.)

这篇关于jQuery Validate,需要阻止免费的电子邮件地址(例如Gmail,Hotmail)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆