Reputation: 748
I am using passwordstrength control to show strength of password entered by user. Now before saving user new password I want to validate that password meets the complexity requirements or strength control showing good. Is there any property of passwordstrength control that gives the current value of password strength?
Upvotes: 1
Views: 2088
Reputation: 1082
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.
Upvotes: 2
Reputation: 1082
[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
Upvotes: 0