jQuery 验证未验证或提交
这是我关于此的第 3 篇文章,但我一直在进行更改,因为没有一个答案能够完全发挥作用(如果验证有效,则提交无效,等等)。
$("#order").validate({ submitHandler: function(form) { $(form).ajaxSubmit(); $("#aciu").show(1000); $("#duomenysdiv").hide(500); }, rules: { vardas: "required", pavarde: "required", adresas: "required", telef: { required: true, digits: true }, email: { required: true, email: true } }, messages: { vardas: "Koks Jusu vardas?", pavarde: "Kokia Jusu pavarde?", adresas: "Kur Jus gyvenate?", telef: { required: "Koks Jusu telefono Nr.?", digits: "Telefono numeryje turetu buti tik skaitmenys" }, email: { required: "Koks Jusu el. pašto adresas?", email: "Iveskite teisinga el. pašto adresa" } } });
我现在真的要疯了,但我不能'似乎没有让它发挥作用。我一整天都在为此苦苦挣扎。
使用此代码,它不会验证。它不显示消息,并且允许我随时提交。当我提交时,它隐藏该 div 并显示另一个 div,并将所需的数据放入 $_POST 中,但它没有像预期的那样工作。
提交以及提交后应该执行的操作完美地进行
$('#order').ajaxForm(function() { $("#aciu").show(1000); $("#duomenysdiv").hide(500); });
,无需验证。
This is my 3rd post about this, but I keep making changes, because none of the answers work in full (if the validation works, the submission doesn't, etc.)
$("#order").validate({ submitHandler: function(form) { $(form).ajaxSubmit(); $("#aciu").show(1000); $("#duomenysdiv").hide(500); }, rules: { vardas: "required", pavarde: "required", adresas: "required", telef: { required: true, digits: true }, email: { required: true, email: true } }, messages: { vardas: "Koks Jusu vardas?", pavarde: "Kokia Jusu pavarde?", adresas: "Kur Jus gyvenate?", telef: { required: "Koks Jusu telefono Nr.?", digits: "Telefono numeryje turetu buti tik skaitmenys" }, email: { required: "Koks Jusu el. pašto adresas?", email: "Iveskite teisinga el. pašto adresa" } } });
I am really going crazy here now, but I just can't seem to make it work. I'm struggling with this all day.
With this code, it doesn't validate. It doesn't show the messages, and it lets me submit whenever I wish. When I submit, it hides the div and shows the other div, and places the required data in $_POST, but it doesn't work like it's supposed to.
The submission and the process what it's supposed to do after the submission works perfectly with just
$('#order').ajaxForm(function() { $("#aciu").show(1000); $("#duomenysdiv").hide(500); });
and no validation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用submitHnadler 而不是单独的.ajaxForm。
Use a submitHnadler insteadof a separate .ajaxForm.