I'm about to realize the validation of a pretty massive form. In some cases I have to compare (conditions) different input values to validate.
Following example given:
function frmDealValidation () {
var validator = $("#frmDeal").validate({
rules: {
product_value: {
required: true,
number: true,
min: 0.01,
}
price: {
required: true,
number: true,
min: 0.01,
max: ($("#show_value1").is(':checked')) ? $("#product_value").val() : 1000000
}
},
submitHandler: function(form) {
form.submit();
}
});
}
As you can see above the max-check depends on a checked radio button and returns a value. That means that the price is not allowed to be greater than the actual product_value.
Assuming the filled in price is greater than the product_value the validation works fine after the first form submit.
Now I can change the values in the inputs to correct the mistakes or if I'm stupid I fill them again with not valid values and hit the submit button (calls frmDealValidation ()
).
Unfortunately the validation didn't update the values from $("#product_value").val()
and seems to use the cached value from the first submit.
I tried validator.resetForm();
as I thought it will force validation to re-validate the whole form and with updated values but with no success!
May I ask for HELP?
Cheers,
Norbert