开发者

Jquery validate - how to require specific options from drop down menu to be selected before validation

If I require one specific option frpm drop down menu to be select开发者_如何学JAVAed before validation of some field, I do like this:

required: "#employmentStatusSTUDENT:selected",

How can I make this requirement to be applied also in case other option is selected?

Something like:

required: "#employmentStatusSTUDENT:selected||#employmentStatusEMPLOYEED:selected",

doesn't work of course...


I am going to guess you could do this similar to how a checkbox or radio is done. Instead of making an option required, set the required to the select node. then give the list of required options a class. I used 'myRequiredOptions:selected'.

required: "#mySelect > option.myRequiredOptions:selected"


Use anonymous function

required: function(){return $("#employmentStatusSTUDENT:selected")||$("#employmentStatusEMPLOYEED:selected");}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜