Password Strength Check Meter for nopCommerce Registration Page...

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Here i am going to show how to implement AJAX password strength check meter....

UPDATE:
FornopCommerce 3.30 and up, see this:  http://www.strivingprogrammers.com/Blog/post/Lavish-Kumar/29/Steps-to-add-password-strength-meter-in-nopCommerce-3-30-register-page/

After struggling with the error message: "Only one instance of a ScriptManager can be added to the page. " finally i was able to do everything successfully..As in nopCommerce we have to add script manager in a little different way...as script manager is already in the nopCommerce project and we can't have more than 1 script manager in 1 page...

Here are the steps.....

1) create a CSS Style Sheet in your root directory (or anywhere as you like, i created it in root directory)

Name your CSS Style Sheet as : passwordStrengthMeter.css

here's the stylesheet code:


.barIndicatorBorder {
border:solid 1px #c0c0c0;
width:200px;
}

.barIndicator_poor {
background-color:gray;
}

.barIndicator_weak {
background-color:orange;
}

.barIndicator_good {
background-color:red;
}

.barIndicator_strong {
background-color:navy;
}

.barIndicator_excellent {
background-color:black;  
}

.textbox {
border: solid 2px #cccccc;
border-top: solid 2px #a0a0a0;
}


.poortext
{
  font-weight:bold;
  color:gray;  
}

.weaktext
{
  font-weight:bold;
  color:orange;  
}

.goodtext
{
  font-weight:bold;
  color:red;  
}

.strongtext
{
  font-weight:bold;
  color:navy;  
}


.excellenttext
{
  font-weight:bold;
  color:black;  
}







2) Now, go to root.master page and add your stylesheet ref like this in between the <head></head> tag:

<link href="../passwordStrengthMeter.css" rel="stylesheet" type="text/css" />




3) Now, go to Modules / CustomerRegister.ascx

Top of this ascx page you will see this:

<div class="registration-page">

under this page put the Script Manager for AJAX tool , it should look like this (Bold code is the code that you have to add):


<div class="registration-page">
<ajaxToolkit:ToolkitScriptManager runat="Server" EnableScriptGlobalization="true"
    EnableScriptLocalization="true" ID="sm1" ScriptMode="Release" CompositeScript-ScriptMode="Release" />

    <div class="page-title">
        <h1><%=GetLocaleResourceString("Account.Registration")%></h1>



4)  Now, in the bottom of this CustomerRegister.ascx page try to find this code:

<asp:TextBox ID="Password" runat="server" MaxLength="50" TextMode="Password"></asp:TextBox>
                                          
                                            <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                                ErrorMessage="<% $NopResources:Account.PasswordIsRequired %>" ToolTip="<% $NopResources:Account.PasswordIsRequired %>"




5) Now, Your have to put the AJAX code for password strength

PASTE this code AFTER <asp:RequiredFieldValidator ID="PasswordRequired"></asp:RequiredFieldValidator> and BEFORE </td>


<ajaxToolkit:PasswordStrength ID="PS" runat="server"
    TargetControlID="Password"
    DisplayPosition="RightSide"
MinimumSymbolCharacters="1"
MinimumUpperCaseCharacters="1"
PreferredPasswordLength="10"
CalculationWeightings="25;25;15;35"
RequiresUpperAndLowerCaseCharacters="true"
TextStrengthDescriptions="Poor; Weak; Good; Strong; Excellent"
HelpStatusLabelID="Label1"
StrengthIndicatorType="BarIndicator"
HelpHandlePosition="AboveLeft"
BarBorderCssClass="barIndicatorBorder"
StrengthStyles="barIndicator_poor; barIndicator_weak; barIndicator_good; barIndicator_strong; barIndicator_excellent">
</ajaxToolkit:PasswordStrength>
<div class="clear"><br /></div>
<asp:Label ID="Label2" runat="server" Text="For Excellent: "></asp:Label>
                                                <asp:Label ID="Label1" runat="server"></asp:Label>
                                                       <br />
                                                <asp:Label ID="Status1" runat="server" Text="Status:  "></asp:Label>
                                                <asp:Label ID="Poor1" runat="server" class="poortext" Text="Poor    "></asp:Label>
                                                <asp:Label ID="Weak1" runat="server" class="weaktext" Text="Weak    "></asp:Label>
                                                <asp:Label ID="Good1" runat="server" class="goodtext" Text="Good    "></asp:Label>
                                                <asp:Label ID="Sgrong1" runat="server" class="strongtext" Text="Strong    "></asp:Label>
                                                <asp:Label ID="Excellent1" runat="server" class="excellenttext"
                                                    Text="Excellent    "></asp:Label>






6) That's it,,,it's done,,now run your project/website > (Don't forget to clear cookies from your browser) > Go to register page > enter the password and you will see the password strength check meter working.....
13 years ago
Explanation of Each and Every property that i used in the AJAX password strength check meter:

    *  TargetControlID - ID of the TextBox to attach to
    * DisplayPosition - Positioning of the strength indicator relative to the target control
    * StrengthIndicatorType - Strength indicator type (Text or BarIndicator)
    * PreferredPasswordLength - Preferred length of the password
   * PrefixText - Text prefixed to the display text when StrengthIndicatorType=Text
    * TextCssClass - CSS class applied to the text display when StrengthIndicatorType=Text
    * MinimumNumericCharacters - Minimum number of numeric characters
    * MinimumSymbolCharacters - Minimum number of symbol characters (ex: $ ^ *)
    * RequiresUpperAndLowerCaseCharacters - Specifies whether mixed case characters are required
    * MinimumLowerCaseCharacters - Only in effect if RequiresUpperAndLowerCaseCharacters property is true. Specifies the minimum number of lowercase characters required when requiring mixed case characters as part of your password strength considerations.
    * MinimumUpperCaseCharacters - Only in effect if RequiresUpperAndLowerCaseCharacters property is true. Specifies the minimum number of uppercase characters required when requiring mixed case characters as part of your password strength considerations.
    * TextStrengthDescriptions - List of semi-colon separated descriptions used when StrengthIndicatorType=Text (Minimum of 2, maximum of 10; order is weakest to strongest)
    * CalculationWeightings - List of semi-colon separated numeric values used to determine the weighting of a strength characteristic. There must be 4 values specified which must total 100. The default weighting values are defined as 50;15;15;20. This corresponds to password length is 50% of the strength calculation, Numeric criteria is 15% of strength calculation, casing criteria is 15% of calculation, and symbol criteria is 20% of calculation. So the format is 'A;B;C;D' where A = length weighting, B = numeric weighting, C = casing weighting, D = symbol weighting.
    * BarBorderCssClass - CSS class applied to the bar indicator's border when StrengthIndicatorType=BarIndicator
    * BarIndicatorCssClass - CSS class applied to the bar indicator's inner bar when StrengthIndicatorType=BarIndicator
    * StrengthStyles - List of semi-colon separated CSS classes that are used depending on the password's strength. This property will override the BarIndicatorCssClass / TextIndicatorCssClass property if present. The BarIndicatorCssClass / TextIndicatorCssClass property differs in that it attributes one CSS style to the BarIndicator or Text Strength indicator (depending on which type is chosen) regardless of password strength. This property will cause the style to change based on the password strength and also to the number of styles specified in this property. For example, if 2 styles are defined like StrengthStyles="style1;style2" then style1 is applied when the password strength is less than 50%, and style2 is applied when password strength is >= 50%. This property can have up to 10 styles.
    * HelpStatusLabelID - Control ID of the label used to display help text
    * HelpHandleCssClass - CSS class applied to the help element used to display a dialog box describing the password requirements
    * HelpHandlePosition - Positioning of the help handle element relative to the target control[b][/b]
13 years ago
Mike,

Thanks a lot
13 years ago
Could go into a user control of its own?

Andrei will you be putting this or something like it into the official release?
13 years ago
kingboyk wrote:
Andrei will you be putting this or something like it into the official release?

I've created the work item for this task
11 years ago
How to enable this on nop 2.65?
11 years ago
could be in 2.7
11 years ago
keval173 wrote:
How to enable this on nop 2.65?

Out of the box: In admin>configuration>settings>All settings  find and change customersettings.passwordminlength
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.