我想用ajax添加验证码
好吧,我有一个表单,其中有电子邮件和验证码验证,但现在我想做一些事情,例如如果验证码不正确或留空,那么我的表单不得重新加载页面,即所有已填写的字段不得获取空白的。
well i have a form in which email and captcha validation was there but now i want to do some thing like if captcha is incorrect or left empty than my form must not reload the page i.e all those field which are already been filled out must not get blank.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以
A)像您现在一样提交表单,并使用现有字段数据填充字段
B) 使用支持 AJAX 提交的验证码库,例如 reCAPTCHA http: //wiki.recaptcha.net/index.php/Overview#AJAX_API
我相信 (A) 更好,因为它允许您可以无缝地处理所有其他类型的验证。但根据您已有的内容 (B) 实施起来可能很简单。所以YMMV。
You can either
A) Submit the form as you are doing right now, and fill the fields with the existing field data
B) Use a CAPTCHA library that supports AJAX submission, e.g. reCAPTCHA http://wiki.recaptcha.net/index.php/Overview#AJAX_API
I believe that (A) is a lot better because it allows you to deal seamlessly with all other kinds of validation. But depending on what you already have (B) might be trivial to implement. So YMMV.