是否有任何属性的密码强度控制的ajax工具包返回强度值

时间:2012-12-05 09:15:14

标签: c# asp.net ajax

我使用passwordstrength控件来显示用户输入的密码强度。在保存用户新密码之前,我想验证密码是否满足复杂性要求或强度控制显示良好。 passwordstrength控件是否有任何属性可以提供密码强度的当前值?

2 个答案:

答案 0 :(得分:2)

You can try something like that:
<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:TextBox ID="TextBox2" Width="150" TextMode="Password" runat="server" autocomplete="off" onkeypress="getPasswordStrengthState()" /><br />
        <asp:Label ID="TextBox2_HelpLabel" runat="server"/><br />
        <br />
        <ajaxToolkit:PasswordStrength ID="PasswordStrength2" BehaviorID="myPSBID" runat="server" TargetControlID="TextBox2"
            DisplayPosition="RightSide" StrengthIndicatorType="BarIndicator" PreferredPasswordLength="15"
            HelpStatusLabelID="TextBox2_HelpLabel" StrengthStyles="BarIndicator_TextBox2_weak;BarIndicator_TextBox2_average;BarIndicator_TextBox2_good"
            BarBorderCssClass="BarBorder_TextBox2" MinimumNumericCharacters="1" MinimumSymbolCharacters="1"
            TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent" RequiresUpperAndLowerCaseCharacters="true" />
        <asp:Button ID="Button1" runat="server" Text="Button" style="display:none"/>
        <script type="text/javascript" language="javascript">
            function getPasswordStrengthState(){
               if( $find("myPSBID")._getPasswordStrength()>50){
                    $get("<%=Button1.ClientID%>").style.display = '';
               }
            }
        </script>
    </form>

PasswordStrength has also CalculationWeightings property on server side.

答案 1 :(得分:0)

[CSS Exemple][1]
    <ajaxToolkit:PasswordStrength ID="PS" runat="server"  
        TargetControlID="TextBox1"  
        DisplayPosition="RightSide"  
        StrengthIndicatorType="Text"  
        PreferredPasswordLength="10"  
        PrefixText="Strength:"  
        TextCssClass="TextIndicator_TextBox1"  
        MinimumNumericCharacters="0"  
        MinimumSymbolCharacters="0"  
        RequiresUpperAndLowerCaseCharacters="false"  
        TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"  
        TextStrengthDescriptionStyles="cssClass1;cssClass2;cssClass3;cssClass4;cssClass5  
        CalculationWeightings="50;15;15;20" /> 




  [1]: http://csharpdotnetfreak.blogspot.com/2012/01/passwordstrength-ajax-aspnet.html