I have validation on form field which works ok. When I click on element in page, I take value of it, put it into form field and I want to change min value in validation to this value I tried rules method but it looks it is not working, but no error is shown
this is my validation call
$('form').validate({
lang: 'sk',
rules: {
'payment[amount]': {
min: 1
}
},
highlight: function(element) {
$(element).parent().addClass('state-error');
},
unhighlight: function(element) {
$(element).parent().removeClass('state-error');
}
});
and this is my function running when I click on element
$( "rewardbox" ).click(function() {
$val = $( this ).children("amount").text();
$num = parseInt($val);
$("#payment_amount").val($num);
$('html, body').animate({ scrollTop: 0 }, 'slow');
$( "#form" ).rules( "remove", "min" );
$("#form").rules("add", {
'payment[amount]':{
min: function () { return $("#payment_amount").val() }
}
});
});
I tried to put as min value directly my variable $num but no luck
how this should work?