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.Implement dynamic Password Policy from database using RegularExpression Validator in ASP.Net<p>You can bring the Password policy is Active ot not from Database. But here i am switching the Regular Expression Validator using DropDownList.</p> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;asp:DropDownList ID=&#34;ddlPasswordPolicy&#34; runat=&#34;server&#34; AutoPostBack=&#34;true&#34; OnSelectedIndexChanged=&#34;DropDownList_OnSelectedIndexChanged&#34;&gt; &lt;asp:ListItem Text=&#34;Please Select&#34; Value=&#34;-1&#34; /&gt; &lt;asp:ListItem Text=&#34;Only 8 Characters&#34; Value=&#34;0&#34; /&gt; &lt;asp:ListItem Text=&#34;With Password Policy&#34; Value=&#34;1&#34; /&gt; &lt;/asp:DropDownList&gt; &lt;div&gt; &lt;u&gt;Minimum 8 characters atleast 1 UpperCase Alphabet, 1 LowerCase Alphabet, 1 Number and 1 Special Character&lt;/u&gt; &lt;b&gt;OR&lt;/b&gt; &lt;u&gt;Minimum 8 characters atleast Character&lt;/u&gt; &lt;br /&gt; Example: PaSs@123 OR pAss@123 &lt;br /&gt; &lt;br /&gt; &lt;asp:TextBox ID=&#34;txtPolicy4&#34; runat=&#34;server&#34;&gt;&lt;/asp:TextBox&gt;&lt;br /&gt; &lt;asp:RegularExpressionValidator ID=&#34;Regex4&#34; runat=&#34;server&#34; ControlToValidate=&#34;txtPolicy4&#34; Display=&#34;Dynamic&#34; ValidationExpression=&#34;^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&amp;])[A-Za-z\d$@$!%*?&amp;]{8,}&#34; ErrorMessage=&#34;Password must contain: Minimum 8 characters atleast 1 UpperCase Alphabet, 1 LowerCase Alphabet, 1 Number and 1 Special Character&#34; ForeColor=&#34;Red&#34; /&gt; &lt;asp:RegularExpressionValidator ID=&#34;Regex&#34; runat=&#34;server&#34; ValidationExpression=&#34;\S{8,8}&#34; ControlToValidate=&#34;txtPolicy4&#34; Display=&#34;Dynamic&#34; ErrorMessage=&#34;Password must contain: Minimum 8 characters Character&#34; ForeColor=&#34;Red&#34; /&gt; &lt;/div&gt; &lt;/form&gt;</pre> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">protected void DropDownList_OnSelectedIndexChanged(object sender, EventArgs e) { if (this.ddlPasswordPolicy.SelectedItem.Value == &#34;0&#34;) { this.Regex4.Enabled = false; } else { this.Regex4.Enabled = true; } }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/848773/Implement-dynamic-Password-Policy-from-database-using-RegularExpression-Validator-in-ASPNet/https://www.aspforums.net:443/Threads/848773/Implement-dynamic-Password-Policy-from-database-using-RegularExpression-Validator-in-ASPNet/Mon, 02 Jun 2014 04:36:35 GMT