I am trying to create a registration page for my company, and so I put down Password and “Repeat Password” textboxes on my form, along with a CompareValidator. It appears to work just fine, whenever users go into both fields, type data and click the Register/Submit button.
However, I’ve noticed an issue where my Firefox browser during testing saves a password that I entered. After it’s saved the password, if I then go back to the page “fresh”, it shows the password already filled in the Password field (though not in the “Repeat Password” field for some reason).
Anyways, if I then populate the e-mail address, I can then click the Register/Submit button with no issues at all!
The most concerning thing is, when I debug into the CodeBehind and even force a validation by triggering both the control’s Validate method and the Page’s Validate method manually, it still somehow PASSES the validation even though, as you can see in the QuickWatches in my screenshot below, the fields have two different values!
Have I found a bug that I should report to Microsoft, or is it possible that I did something wrong in setting this all up? All I did was plop the CompareValidator on the form, and set the “ControlToCompare” to “txtUserPass” and the “ControlToValidate” to “txtRepeatPass”, and the Operation is set to “Equal”.
Am I perhaps doing something wrong here, or have I found a genuine bug caused by browsers storing passwords?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
As specified on the documentation, the CompareValidator does not trigger for empty values:
If the input control is empty, no validation functions are called and validation succeeds. Use a RequiredFieldValidator control to require the user to enter data in the input control.
You need to combine the CompareValidator with a RequiredFieldValidator.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

