I'm sure there's a better way to implement this but can't figure it out. I have a form which has 2 fields at the top that are always required. I then have a series of tabs which load in different fields when selected (separate chunks of HTML loading in, so that only what's currently in the DOM is submitted when the form submits). I'm using the jquery validation plugin ( http://docs.jquery.com/Plugins/Validation ) which allows you to set the validation rules/messages as an object when each set of new fields loads in, to remove redundant rules and add new ones as the fields change. Problem is the rules/messages objects all have to be written into the js for use when required and the file is long and it seems very inefficient. Here's my pseudocode:
<form>
<input1 (always on page) />
<input2 (always on page) />
<ul id="nav-tabs">
<li id="tab1"></li>
<li id="tab2"></li>
<li id="tab3"></li>
</ul>
<div id="dynamic-content">
<!-- different form fields load in here from separate html files, all requiring different rules in addition to the 2 fields always on the page -->
</div>
<input type="submit" />
</form>
I'm thinking there might be some solution with loading in the rules with each chunk of HTML as it is set? Has anyone done anything like this?
Thanks to anyone who can help. T