Question problem with compare validator

pooya1072

Well-known member
Joined
Jul 5, 2012
Messages
84
Programming Experience
Beginner
hi
i have 2 textbox in my webform ; for type and retype the password.i put a compare validator to control the second textbox so it's value be equal by first textbox.so i enter the password in first textbox .at this time second textbox is empty.but compare validator don't work.only if i enter a non equal value by first textbox , the compare validator work .why it happen?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,292
Location
Sydney, Australia
Programming Experience
10+
May I suggest in future that, if you try to use something and it doesn't work, the first thing you do is read the documentation for the class or member that you're trying to use? The documentation is there for a reason. Use it. This is from about 10 seconds worth of reading into the documentation for the CompareValidator class:
Validation succeeds if the input control is empty. Use a RequiredFieldValidator control to require the user to enter data into the input control.
 

nayanpatel

Active member
Joined
Nov 18, 2016
Messages
27
Location
ahmedabad
Programming Experience
3-5
You have to use required field validator and compare validator both for the confirm password input.So,if the user leave text box empty it shows required field validation and if user enter different value than the password field it shows password not matched validation.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,292
Location
Sydney, Australia
Programming Experience
10+
You have to use required field validator and compare validator both for the confirm password input.So,if the user leave text box empty it shows required field validation and if user enter different value than the password field it shows password not matched validation.
I wish I'd said that 4 1/2 years ago. Oh look, I did! ;-)
 
Top Bottom