Is it possible to use Password strength indicator with RegularExpressionValidator

Donald Symmons 2,856 Reputation points

How can I create a password indicator strength when I already made use of RegurlarExpressionVaidator?

<asp:TextBox ID="passwordTxt" runat="server" TextMode="Password" CssClass="form-control" Font-Size="11pt" placeholder="User Password" />

In my RegularExpressionValidator, I made the password to accept Alphanumeric and Special characters, and also the minimum accepted characters are 10

<asp:RegularExpressionValidator ID="Regex" runat="server" Font-Size="8pt" ErrorMessage="Minimum of 10 characters including UpperCase, LowerCase, Number and Special Character" ValidationExpression="(?=^.{12,}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&amp;*()_+}{&quot;:;'?/&gt;.&lt;,])(?!.*\s).*$" ControlToValidate="passwordTxt" ForeColor="Red"></asp:RegularExpressionValidator><br />

Can I have both RegularExpressionValidator and also create password Strength indicator?

Microsoft Technologies based on the .NET software framework.
3,459 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
3,315 questions
{count} votes

Accepted answer
  1. QiYou-MSFT 4,306 Reputation points Microsoft Vendor

    Hi @Donald Symmons

    I would like to recommend you a control: "AjaxControlToolkit.PasswordStrength".

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

     <style type="text/css">
             padding: 2px 3px 2px 3px;
                <asp:ScriptManager ID="ScriptManager1" runat="server"/>
                <asp:TextBox ID="TextBox1" runat="server" TextMode="Password" CssClass="form-control" Font-Size="11pt" placeholder="User Password" />
                 <asp:Panel ID="Panel1" runat="server"  Height="100px" Width="500px">
                 <ajaxToolkit:PasswordStrength ID="PasswordStrength1" runat="server" TargetControlID="TextBox1"
                      DisplayPosition="RightSide" TextCssClass="aaa" HelpHandlePosition="BelowLeft"
                MinimumNumericCharacters="2" MinimumSymbolCharacters="2" StrengthIndicatorType="BarIndicator"
                PrefixText="Password strength:" PreferredPasswordLength="10" RequiresUpperAndLowerCaseCharacters="true"
                TextStrengthDescriptions="Very poor;Poor;Normal;Well;Very Well" CalculationWeightings="40;20;20;20" BarIndicatorCssClass="bartype"

    I'll explain to you the meaning of a few properties:

    TargetControlID The ID of the TextBox control to detect the password
    DisplayPosition The location of the password strength message, e.g. **DisplayPosition="RightSide LeftSide BelowLeft"**
    StrengthIndicatorType Intensity information prompts, including text and progress bars **StrengthIndicatorType="Text BarIndicator"**
    PreferredPasswordLength The length of the password
    PrefixText When using text as a text, the text at the beginning of PrefixText="Intensity:"
    TextCssClass CSS styles for text when using text squares
    MinimumNumericCharacters The minimum number of digits to include in the password
    MinimumSymbolCharacters The best number of symbols to include in the password (*, #)
    RequiresUpperAndLowerCaseCharacters Whether case sensitivity is required
    TextStrengthDescriptions Text prompt information in text modeTextStrengthDescriptions="extremely weak; Weak; Medium; Strong; Great"
    BarIndicatorCssClass CSS style for the progress bar
    BarBorderCssClass CSS style for progress bar borders
    HelpStatusLabelID The ID of the Lable control for help prompts
    CalculationWeightings The proportion of the password constituent department, the value of which is in the format "A; B; C; D”. where A represents the specific gravity of length, B represents the specific gravity of numbers, C represents the specific gravity of uppercase, and D represents the specific gravity of special symbols. The sum of the four values A, B, C, and D must be 100, and the default value is "50; 15; 15;20”

    In the code I gave you, I set the password length to 10. A minimum of two characters and numbers are required.


    1.Scroll bar mode


    2.Text mode


    Best Regards,

    Qi You

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

1 additional answer

Sort by: Most helpful
  1. Hitesh Chauhan 0 Reputation points

    A password strength checker is a tool or algorithm designed to evaluate the security strength of a password. It analyzes various factors, such as length, complexity, and uniqueness, to determine the overall robustness of a password and assess its vulnerability to being guessed or cracked.

    The importance of using strong passwords cannot be overstated in today's digital landscape, where cyber threats are prevalent. Weak passwords make it easier for attackers to gain unauthorized access to personal accounts, sensitive information, or even entire systems. A password strength checker helps users create stronger passwords by providing feedback and guidance on creating more secure combinations.

    0 comments No comments