ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Toggle Multiple RegularExpression Validators for one TextBox based on RadioButton selection in ASP.Net<p>With reference of this article.</p> <h1 class="header"><a title="Enable Disable ASP.Net Validator (Client Side Validation) using JavaScript or jQuery'a" href="http://aspsnippets.com/Articles/Enable-Disable-ASPNet-Validator-Client-Side-Validation-using-JavaScript-or-jQuery.aspx">Enable Disable ASP.Net Validator (Client Side Validation) using JavaScript or jQuery</a></h1> <p>&nbsp;</p> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head id=&#34;Head1&#34; runat=&#34;server&#34;&gt; &lt;style type=&#34;text/css&#34;&gt; body { font-family: Arial; font-size: 10pt; } &lt;/style&gt; &lt;title&gt;&lt;/title&gt; &lt;script src=&#34;https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js&#34; type=&#34;text/javascript&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; function ToggleValidator() { var valNumber = document.getElementById(&#34;&lt;%=valNumbers.ClientID%&gt;&#34;); var valAlphaNumeric = document.getElementById(&#34;&lt;%=valAlphaNumeric.ClientID%&gt;&#34;); var radioButton = document.getElementById(&#34;&lt;%=rblValidationType.ClientID %&gt;&#34;).getElementsByTagName(&#34;input&#34;); var selectedValue; for (var i = 0; i &lt; radioButton.length; i++) { if (radioButton[i].checked == true) { selectedValue = radioButton[i].value; } } switch (selectedValue) { case &#34;0&#34;: ValidatorEnable(valNumber, true); ValidatorEnable(valAlphaNumeric, false); break; case &#34;1&#34;: ValidatorEnable(valNumber, false); ValidatorEnable(valAlphaNumeric, true); break; case &#34;2&#34;: ValidatorEnable(valNumber, false); ValidatorEnable(valAlphaNumeric, false); break; } if (Page_IsValid) { return false; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;div&gt; &lt;asp:RadioButtonList ID=&#34;rblValidationType&#34; runat=&#34;server&#34;&gt; &lt;asp:ListItem Text=&#34;Numeric&#34; Value=&#34;0&#34; /&gt; &lt;asp:ListItem Text=&#34;Alphanumeric&#34; Value=&#34;1&#34; /&gt; &lt;asp:ListItem Text=&#34;None&#34; Value=&#34;2&#34; /&gt; &lt;/asp:RadioButtonList&gt; &lt;asp:TextBox ID=&#34;txtReportBy&#34; runat=&#34;server&#34; /&gt; &amp;nbsp; &lt;asp:Button ID=&#34;btnValidate&#34; Text=&#34;Validate&#34; runat=&#34;server&#34; ValidationGroup=&#34;ValidationType&#34; OnClientClick=&#34;ToggleValidator()&#34; /&gt; &lt;br /&gt; &lt;asp:RegularExpressionValidator ID=&#34;valNumbers&#34; ErrorMessage=&#34;Please enter only numbers&#34; ControlToValidate=&#34;txtReportBy&#34; runat=&#34;server&#34; ValidationExpression=&#34;^[0-9]*$&#34; Display=&#34;Dynamic&#34; Enabled=&#34;false&#34; ForeColor=&#34;Red&#34; ValidationGroup=&#34;ValidationType&#34; /&gt; &lt;asp:RegularExpressionValidator ID=&#34;valAlphaNumeric&#34; ForeColor=&#34;Red&#34; ErrorMessage=&#34;Please enter only alphanumeric values&#34; ControlToValidate=&#34;txtReportBy&#34; runat=&#34;server&#34; ValidationExpression=&#34;^[0-9a-zA-Z]*$&#34; Enabled=&#34;false&#34; ValidationGroup=&#34;ValidationType&#34; Display=&#34;Dynamic&#34; /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><span style="text-decoration: underline;">Screenshot</span></p> <p><img src="https://i.imgur.com/ZCCQpTh.png" alt="" width="254" height="259" /></p>https://www.aspforums.net:443/Threads/885274/Toggle-Multiple-RegularExpression-Validators-for-one-TextBox-based-on-RadioButton-selection-in-ASPNet/https://www.aspforums.net:443/Threads/885274/Toggle-Multiple-RegularExpression-Validators-for-one-TextBox-based-on-RadioButton-selection-in-ASPNet/Wed, 24 Sep 2014 03:49:39 GMT