I have two hidden input fields on my form that I have linked to jquery validation rules. These are sort of "global" form rules (for example the total of multiple fields not equal to 100%), so I am using hidden fields at the top of my form to show a message that applies to the whole form.
They are defined like this:
<input type="hidden" class="futuretotalsunder"/>
<input type="hidden" class="futuretotalsrequired"/>
Here are my rule definitions. You can get the idea of it. The first rule checks to see if a bunch of text boxes total up to < 100, and the second check to make sure the total isn't 0. The problem is, the only one that fires is whichever one is applies to the first hidden input element. The second one never fires. Any idea why?
$.validator.addMethod("futuretotalsunder", function (val, element, params) {
alert("under");
var total = 0;
$(".TransferPercentTextBox").each(function () {
total = total + parseInt($(this).val());
});
if ((total < 100) && (total != 0)) {
window.location.href = "#Top";
return false;
}
else {
return true;
}
}, "Total percentage must equal 100%.");
$.validator.addMethod("futuretotalsrequired", function (val, element, params) {
var total = 0;
$(".TransferPercentTextBox").each(function () {
total = total + parseInt($(this).val());
});
if (total == 0) {
window.location.href = "#Top";
return false;
}
else {
return true;
}
}, "Transfer amount must be greater than 0.");