Is it possible to use Password strength indicator with RegularExpressionValidator

Donald Symmons 3,066 Reputation points
2023-04-12T12:38:32.1533333+00:00

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?

Developer technologies .NET Other
Developer technologies ASP.NET Other
{count} votes

Accepted answer
  1. QiYou-MSFT 4,326 Reputation points Microsoft External Staff
    2023-04-13T07:03:38.6+00:00

    Hi @Donald Symmons

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

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

     <style type="text/css">
     .bartype
    {
    
      color:blue;
    
      background-color:green;
    
    }
    
     .barborder
    
    {
    
     border-style:solid;
    
     border-width:1px;
    
     width:100px;
    
     vertical-align:middle;
    
    }
    
          .aaa
    
          {
    
          background-color:#047AFD;
    
     
    
             color:#ffffff;
    
     
    
             font-family:Arial;
    
     
    
             font-size:9pt;
    
     
    
             padding: 2px 3px 2px 3px;
    
          }
      </style>
    
    <div>
                <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"
                BarBorderCssClass="barborder">
                </ajaxToolkit:PasswordStrength>
                     </asp:Panel>
            </div>
    

    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.

    OutPut

    1.Scroll bar mode

    Scroll

    2.Text mode

    Text

    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
    2023-05-17T02:52:25.05+00:00

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.