jquery validate - 如果隐藏字段有值,则有效 [英] jquery validate - valid if hidden field has a value
本文介绍了jquery validate - 如果隐藏字段有值,则有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要根据隐藏字段的值验证字段。我尝试了这个自定义规则:
I need to validate a field based on the value of a hidden field. I tried this custom rule:
jQuery.validator.addMethod("cityselected", function() {
if ($('#featureID').val() == "") return false;
else return true;
});
cityselect: {
required: true,
cityselected: true
},
featureID是一个隐藏的输入,我需要检查它有一个值。这似乎不起作用。任何想法?
featureID is a hidden input which I need to check has a value. This doesnt seem to work though. Any ideas?
推荐答案
将必需类添加到隐藏输入中。
Add the class "required" to the hidden input.
这篇关于jquery validate - 如果隐藏字段有值,则有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文