JsonStatham
JsonStatham

Reputation: 10364

Default validation for ChangePassword control in ASP webforms

I'm using the ASP ChangePassword control to assist users with changing their passwords, I've noticed that some passwords would not change when I filled out the form then clicked 'Change Password' this was because they did not contain at least 1 non-alpha-numeric character, I think this is the default behaviour.

So I have added the following:

                            <asp:RegularExpressionValidator
                                ID="ProgrammaticID"
                                ControlToValidate="NewPassword"
                                ValidationExpression='^[a-zA-Z]\w{3,14}$'
                                ErrorMessage="The password's first character must be a letter, it must contain at least 4 characters and no more than 15 characters and no characters other than letters, numbers and the underscore may be used"
                                Text="The password's first character must be a letter, it must contain at least 4 characters and no more than 15 characters and no characters other than letters, numbers and the underscore may be used"
                                ForeColor="red"
                                BackColor="white"
                                runat="server"></asp:RegularExpressionValidator>   

The validation is working as expected now on the actual pop-up form, however, how do I change the default validation that the actual control works with to match what I want, not what the control wants?

I cannot find anything in the properties, and I am guessing what the default rules are, my RegularExpressionValidator is useless until I can make the control follow these rules rather than submitting even though the validation did not pass.

Upvotes: 0

Views: 269

Answers (1)

codingbiz
codingbiz

Reputation: 26386

You are looking in the wrong place. You don't need Regular Expression to change that behavior. I believe it is set in the web.config

minRequiredNonalphanumericCharacters="1"

<membership>
      <providers>
        <add name="AspNetSqlMembershipProvider"     

        minRequiredNonalphanumericCharacters="1" 
        ... />
      </providers>

</membership>

Upvotes: 1

Related Questions