Only display .NET PasswordStrength Control after 6 characters?
Anyone have any ideas on how to hide the .NET PasswordStrength control until after 6 characte开发者_C百科rs have been typed? The control doesn't seem to support this so I'm guessing I'd have to wrap something around it maybe? Thoughts?
Unless you're doing a postback on every keystroke in the textbox (please don't do that! :), you'll need to use client-side script to do this work.
Easiest way I can think of is to hook the textfield's onkeyup event: have it call a javascript function which evaluates the length of the text in the field. If length is greater than 6 use CSS ('display: block;' most likely) to show the passwordStrength control; otherwise hide the control ('display: none').
Note: this doesn't account for paste operations into the text box - but since it's a password field, you probably don't want to allow paste into it anyway.
精彩评论