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>
LVL 1
net_susanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

craskinCommented:
are you using a validation summary? generally, validator controls have an errormessage property set that sends an error message to a validation summary which should run at submit.
0
strickddCommented:
<asp:comparevalidator id="comparepw" Runat="server" ControlToValidate="password" controlToCompare="confirmpw" EnableClientScript = "true">
Password and confirm password do not match!</asp:comparevalidator>

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"

Both of those should work for you. The Second will reduce the number of server requests.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aki4uCommented:
Add  EnableClientScript="False"

so it looks like this:
<asp:comparevalidator id="comparepw" Runat="server" ControlToValidate="password" controlToCompare="confirmpw" EnableClientScript="False">
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

net_susanAuthor Commented:
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"
0
net_susanAuthor Commented:
Thanks everyone!
0
strickddCommented:
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.
0
net_susanAuthor Commented:
If you see this, please explain what this means:

Sorry, mixed up those stupid bool validators,


I'm just a .NET baby.  :)
0
strickddCommented:
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.
0
net_susanAuthor Commented:
Ah, thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.