[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

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>
0
net_susan
Asked:
net_susan
3 Solutions
 
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
 
aki4uCommented:
Add  EnableClientScript="False"

so it looks like this:
<asp:comparevalidator id="comparepw" Runat="server" ControlToValidate="password" controlToCompare="confirmpw" EnableClientScript="False">
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now