javascript - ValidatorEnable not disabling requiredfieldvalidator -
i have client side script in aspx file enables or disables required field validator based on whether form field visible or not.
var oval1 = document.getelementbyid(v1); var oval2 = document.getelementbyid(v2); validatorenable(oval1, true); validatorenable(oval2, false);
when alert enabled properties of oval1 , oval2, show correct settings condition - oval1 enabled, oval2 disabled.
the problem validators firing. need selectively disable 1 since field isn't visible, it's not required in case.
try this...
var controlandvalidator = { "controlnamegoeshere" : "0"//validate 1, not validate : 0 }; $(document).ready(function () { // or trigger u want $.each(controlandvalidator, function (index, validate) { var validatorname = document.getelementbyid(index); if (validatorname != null) { validatorenable(validatorname, parseint(validate) == 1 ? true : false); } });
Comments
Post a Comment