Hi Team,
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.
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?
Please advise.
rdbDetail.Attributes.Add("onclick", "EnableRequiredFieldValidator();");
rdbSummary.Attributes.Add("onclick", "DisableRequiredFieldValidator();");
Javascript:
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)
}
}
Thanks
Lijo