This seems like it should have a simple solution but I can't seem to find it.
I'm using the ChangePassword control in an ASP.NET 2.0 application, using both the ChangePasswordTemplate and SuccessTemplate to define custom styling. The textboxes have IDs as follows
Current Password Textbox ID = CurrentPassword
New Password Textbox ID = NewPassword
Confirm New Password Textbox ID = ConfirmPassword
For DRY reasons, I want to use the regular expression that is defined in the Custom Membership Provider to validate the new password client side. Unfortunately, setting the ChangedPassword control's property as follows
ChangePassword.NewPasswordRegularExpression =
Membership.PasswordStrengthRegularExpression;
ChangePassword.NewPasswordRegularExpressionErrorMessage =
"Regex Error Message";
in Page_Init sets the expression to the expected value, but does not cause client side validation to happen on the new password (the page posts back and the standard Membership ChangePassword failure text gets displayed).
I could use a RegularExpressionValidator in the ChangePasswordTemplate and set the ValidationExpression property to Membership.PasswordStrengthRegularExpression but the best way that I can see to do this requires recursing through the controls in the template to find the RegularExpressionValidator and setting the property, which makes me believe that there must be a more elegant way. I have other validator controls in the template (required fields and a compare validator), in case this may be causing a conflict with using the ChangePassword validation properties.
My question is then, does the ChangePassword control's NewPasswordRegularExpression property work when using templates or do I need to go down the RegularExpressionValidator control route?
EDIT:
Offered up a bounty on this as I can't find a definitive answer as to why the ChangePassword control's NewPasswordRegularExpression property does not validate client side.