How to validate specific hidden fileds in mvc using jquery validation plug in

醉酒当歌 提交于 2019-12-24 14:51:56

问题


In my form have multiple hidden fields when I try with

 $("#formid").data("validator").settings.ignore ="" it validate all the hidden filed.

try this also $("#start-a-request-full-form").data("validator").settings.ignore = ':is("#hiddenfieldID1 ,#hiddenField2")):hidden'; did not work

My target is to validate only 2 hidden fields with some ID


回答1:


You can add a class name (say) class="ignore" to those hidden inputs you dont want validated and then use

$.validator.setDefaults({ 
  ignore: ".ignore"
});


来源:https://stackoverflow.com/questions/29840056/how-to-validate-specific-hidden-fileds-in-mvc-using-jquery-validation-plug-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!