I have a page with two tables. The first is visible and the second is hidden when the page loads.
If the last two items (in color) in 开发者_JAVA百科the first table have either "Yes" choice selected, then the second table appears.
I need to add validation to make sure all visible items are selected before the form submits. The problem I'm having is that if the second table is hidden (because "No" is selected for items 8 and 9), the form should submit the data from the first table because the second table is not showing. However, if both tables are showing, then all responses are required before the form submits.
http://jsfiddle.net/mrfisherman2010/dvzsf/2/
I would appreciate help on this. I've really been struggling.
Thanks
Use the jQuery validation plugin. It lets you have arbitrary validation rules and dependencies.
"my_field": {
required: {
depends: function(element) {
var result =...some javascript code...;
return result;
}
}
}
精彩评论