My set up is that I have one field called claimaint_rep, now when that value is Yes I want to have multiple fields become required. Now I'm using jquery validate. My code currently is:
$('#aspnetForm').validate({
errorPlacement: function (error, element) { },
rules:
{
claimsol:
{
required: function (element) {
return $("#ctl00_ContentPlaceHolder1_claimant_rep").val() == "Yes";
},
minlength: 2
}
},
highlight: function (element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function (element) {
$(element).closest('.control-group').removeClass('error').addClass('success');
}
});
Example HTML:
<div class="control-group">
<label class="control-label" for="inputEmail">Reference Number</label>
<div class="controls">
<asp:TextBox ID="solicitor_reference" CssClass="span3 claimsol" runat="server"></asp:TextBox>
</div>
</div>
The field naming is due to it being an ASP Webform (ugh), now from what it seems like that the claimsol rule will only apply to one field with an name of claimsol? I want to apply that rule to multiple fields, ideally without having to set each on in the rules section. What am I missing here?