Unobtrusive - adding a method, how to find a dependent property
I am writing an MVC app and I have created a custom validator, now I am trying to write the client side. The intent is "if the dependant property is true (it's a radio") then this value must not be 0".
I am currently unable to get the value of radioValue, so the program fails at that point. What am I doing wrong?
$.validator.addMethod("requiredifyes", function (val, elem, param) {
var dependantProperty = param;
var radioValue = document.getElementByName(dependantProperty).value;
var counterValue = val;
if (dpElement = true) {
if (counterValue = 0) {
return false;
}
}
return true;
});
$.validator.unobtrusive.adapters.addSingleVal("requiredifyes", "othervalue", "requiredifyes");