I am trying to get a dynamically updated value of min in one field, depending on the input from other fields. Here is my code shorter:
$("#new_project").live("click", function() {
switch($('input:radio[name=quality-level]:checked').val()){
case 'average' : ppw = .006;
case 'below-average' : ppw =.004;
case 'good' : ppw = .008;
case 'very-good' : ppw = .016;
}
if ($('#minimum-word-length').val() && $('input:radio[name=quality-level]:checked').val())
{
min_price = $('#minimum-word-length').val() * ppw;
}
$("#new_project, .edit_project").validate({
rules: {
...
"price-per-article": {required: true, number: true, min:min_price},
...
},
errorPlacement: function(error, element) { }
});
});
The minimum price is set correctly and updated correctly. However, for some reason, the minimum value rule does not update, which I believe is because the verification code only loads when the document loads. So I guess there is a way to reload the rules, so that the min value changes when the two required fields are populated?
Thank!
source
share