Link to home
Create AccountLog in
Avatar of net_susan
net_susan

asked on

Compare Validator Reacts Before Sumit is Clicked

This compare validator reacts as soon as a user types in the password, not even giving time to type in the password confirmation. How can I make it so this validator only reacts after submit is clicked?

<asp:comparevalidator id="comparepw" Runat="server" ControlToValidate="password" controlToCompare="confirmpw">
Password and confirm password do not match!</asp:comparevalidator>
SOLUTION
Avatar of craskin
craskin
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of net_susan
net_susan

ASKER

I did this:

This will cause the validator to only fire when the submit button is clicked. Alternatively you can set the ControlToValidate and the ControlToCompare to be opposite:

ControlToValidate="confirmpw" controlToCompare="password"
Thanks everyone!
Sorry, mixed up those stupid bool validators, but still, switching the controltocompare and the controltovalidate is a more efficient way because you don't have to wait for a postback event.
If you see this, please explain what this means:

Sorry, mixed up those stupid bool validators,


I'm just a .NET baby.  :)
in my original post i said to use: EnableClientScript = "true"

then aki4u corrected me by saying: EnableClientScript="False"

I was copying code i previously used in which i wanted to force client scripting and forgot to change "true", a boolen (bool) value, to "False, the opposite boolean value.
Ah, thanks!