How can I add Jquery Validation for multiple textboxes with same name, when their corresponding checkboxes are checked
Jquery:
$("input:[name='abc']").change(function() {
var method = $(this).val();
if ($(this).is(':checked')) {
$("#" + method).spinner({
'disabled': false
});
console.log(method);
$("#" + method).rules("add",{
range: [1, 99],
required : true,
messages: {
range: "Please enter a value between 1 and 99",
required: "Please give a value for " + method
}
});
$("#" + method).val(1);
} else {
$("#" + method).spinner({
'disabled': true
});
console.log(method);
$("#" + method).rules('remove','range');
$("#" + method).rules('remove','required');
$("#" + method).val(0);
}
});
Trying to add and remove rules to textboxes depending upon the checkbox change event.