, max . , .. ().
rules: {
field1:
{
required: true,
max: function () { return $("#mycheckbox:checked").length ? 100 : 50; }
}
}
, , , ,
$('#mycheckbox').on('change', function () {
$('#field1.error').each(function () {
$(this).valid();
});
});
, , , errorClass .
html,
<input name="mycheckbox" id="mycheckbox" type="checkbox" />
<input name="field1" id="field1">
<input type="submit" />
JavaScript ,
$(function () {
$("form").validate({
rules: {
field1:
{
required: true,
max: function () {
return $("#mycheckbox:checked").length ? 100 : 50;
}
}
},
submitHandler: function () {
alert('form ok');
}
});
$('#mycheckbox').on('change', function () {
$('#field1.error').each(function () {
$(this).valid();
});
});
});