Hello guys,
I am just trying to insert the password strength field. For that I have added the label next to password textbox. But I want to show the strength as soon as the user moves to next password field or some other field.
For this I have tried the code with CreatingUser & Databinding events but they do not work as I want. Can you please tell me what event would be beneficial for it so that password strength is shown as soon as user moves to next input field.
My markup is as follows.
Code:
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
Password Strength:
<asp:Label ID="lblPassStr" runat="server" ForeColor="Green" Visible="true"></asp:Label>
</td>
</tr>
And code behind file contains.
Code:
protected void CreateUserWizard1_DataBinding(object sender, EventArgs e)
{
if (CreateUserWizard1.ActiveStep.Title == "CreateUser")
{
Label PassStr = (Label)CreateUserWizardStep1.ContentTemplateContainer.FindControl("lblPassStr");
//PassStr.Visible = true;
if (CreateUserWizard1.Password.Length < 5)
PassStr.Text = "Password Too Short, Not Acceptable";
else if (CreateUserWizard1.Password.Length >= 5 && CreateUserWizard1.Password.Length <= 8)
PassStr.Text = "Password is weak";
else
PassStr.Text = "Password is strong";
}
}
Any help is remarkable.
Thank you.