Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!