Disabling ASP.NET validator using Javascript
<p>I have a RequiredFieldValidator applied for a text box. This text box entry is mandatory only if a radio button is selected(rdbDetail). When the page loads, the rdbDetail will not be selected and hence the Validator should not fire.  (There will be another radio button selected by rdbSummary.). I am using the following javascript logic and it is working fine for the functionality. </p>

<p>The challenge is that when I change the radio button selection to “Detail” it shows the error image, even before clicking the button(btnShowReport). How do I overcome it?</p>

<p>Please advise.</p>

<pre><code>    rdbDetail.Attributes.Add("onclick", "EnableRequiredFieldValidator();");
    rdbSummary.Attributes.Add("onclick", "DisableRequiredFieldValidator();");
</code></pre>

<p>Javascript:</p>

<pre><code>function EnableRequiredFieldValidator()
 {

    var reqValidator = document.getElementById(reqVal);
    if(reqValidator!= 'undefined')
    {
          ValidatorEnable(reqValidator, true) 
    }

 }



 function DisableRequiredFieldValidator()
     {

        var reqValidator = document.getElementById(reqVal);
        if(reqValidator!= 'undefined')
        {
             ValidatorEnable(reqValidator, false) 
        }

    }
</code></pre>

<p>Thanks</p>

<p>Lijo</p>
