I wanted to add conditional rules dynamically on the page load here is my code what I have tried I have created jsfiddle First code sample
$("input[name$='DistanceToRespondingFireDept']").rules("add", {
required: {
depends: function (element) {
return $("input:radio[name='DistanceToNearestFireHydrnt']:checked").val() == 'U';
}
},
messages: {
required: "Tested"
}
});
second code
$("input[name$='DistanceToRespondingFireDept']").rules("add", {
required: function (element) {
return $("input:radio[name='DistanceToNearestFireHydrnt']:checked").val() == 'U';
},
messages: {
required: "Tested"
}
});
I get an error "cannot call method call of undefined"
If I don't add any conditions do just simple required: true it works
Any suggestion how to fix
<html>,<head>or<body>tags in your jsFiddle; just insert the HTML that's between your<body></body>.