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");}
精彩评论