Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey everyone,

i have a combobox and a text box.In either case only one of them is visible.I've applied required field validator to textbox.and used a validation summary.Now,my problem is that i want to use only one control out of them at a time.If i'm not using textbox.I don't want it to validate.How can i avoid that?...

Thanks
Amit
Posted

1 solution

Hi
Amit,

Enable or Disable ASP.Net Validation on client side
rfvOther: is a Required Field Validator
Collapse

C#
//Syntax:
ValidatorEnable(ValidatorContronName,Boolean);
//Explanation:ValidatorContronName - This is ClientID of the Validation control.
Boolean - true(Enable) / false(Disable)
//Example:
ValidatorEnable(document.getElementById('<%=rfvOther.ClientID%>'), fale);


You can implement this function according you logic.


Please do let me know, if you have any doubt.

Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen
 
Share this answer
 
Comments
AmitChoudhary10 28-Oct-10 7:46am    
Hey Sunasara,i got your point.But i am not able to implement it(Like using an if-else condition for controls visibility).I am trying this bit don't know how to check controls visibility--
var cmbName = document.getElementById(cmbName);
var rvComboName = document.getElementById(rvComboName);
var txtName = document.getElementById(txtName);
var rvName = document.getElementById(rvName);
if()
ValidatorEnable(document.getElementById('<%=rvComboName.ClientID%>'), false);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900