Enable / Disable Regular Expression Validator based on Dropdownlist selection
-
Hi Friends, I have DropdownList, Textbox and RegularExpression Validator in Gridview's ItemTemplate. RegularExpressionValidator is to validate the percentage in Textbox entry. This RegularExpressValidator should enable only based on dropdownlist selection. i.e., if dropdownlist selection is "Percentage" then, validator should enable to validate textbox entry. I have tried many ways in Javascript and .cs code, but no luck. Please help in this. Regards, Priyaa.
-
Hi Friends, I have DropdownList, Textbox and RegularExpression Validator in Gridview's ItemTemplate. RegularExpressionValidator is to validate the percentage in Textbox entry. This RegularExpressValidator should enable only based on dropdownlist selection. i.e., if dropdownlist selection is "Percentage" then, validator should enable to validate textbox entry. I have tried many ways in Javascript and .cs code, but no luck. Please help in this. Regards, Priyaa.
Replace you RegularExpression Validator with a Custom Validator, then you can use string.match js method to validate you textbox. here is a link on how to use the string.match() method: string.match()
-
Hi Friends, I have DropdownList, Textbox and RegularExpression Validator in Gridview's ItemTemplate. RegularExpressionValidator is to validate the percentage in Textbox entry. This RegularExpressValidator should enable only based on dropdownlist selection. i.e., if dropdownlist selection is "Percentage" then, validator should enable to validate textbox entry. I have tried many ways in Javascript and .cs code, but no luck. Please help in this. Regards, Priyaa.
Hi, you can use dropdown selected index changed event on dropdownlist. means if your regular expression validator id is regular1 then just false its visibility from server side as reqular1.Visible=false; try it. this can also done by Jquery.
-
Hi Friends, I have DropdownList, Textbox and RegularExpression Validator in Gridview's ItemTemplate. RegularExpressionValidator is to validate the percentage in Textbox entry. This RegularExpressValidator should enable only based on dropdownlist selection. i.e., if dropdownlist selection is "Percentage" then, validator should enable to validate textbox entry. I have tried many ways in Javascript and .cs code, but no luck. Please help in this. Regards, Priyaa.
Hi, This can be achieved by using the inbuilt ValidatorEnable function. Refer http://msdn.microsoft.com/en-us/library/aa479045.aspx[^] for more information.
When you fail to plan, you are planning to fail.