jquery.validate验证禁用字段 [英] jquery.validate validating disabled field
本文介绍了jquery.validate验证禁用字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在表单中有一个下拉列表,它控制使用jQuery的.show()和.hide()在表单上启用/禁用哪些字段。在我的jquery.validate规则中,我有所需的所有字段。
I have a drop down in a form which controls which fields will be enabled/disabled on the form using jQuery's .show() and .hide(). In my jquery.validate rules, I have all the fields as required.
这是我的jquery.validate规则的样子
This is what my jquery.validate rule looks like
$("#new_course").validate({
ignore: ":disabled",
rules: {
"course_init_on": {required: true},
"mins_before": {required: true},
.....
使用上面的代码仍然验证隐藏的字段并停止提交表单。
With the code, above it still validates the field that are hidden and stops the form from submitting.
推荐答案
我能看到的是你添加了忽略 :禁用不同于:隐藏
What I can see is that you have added ignore ":disabled" which is different than ":hidden"
我认为你应该使用:
$("#new_course").validate({
ignore: ":hidden",
...
这篇关于jquery.validate验证禁用字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文