1

I have a <input> with an onclick event which checks for the Enter key. The called function may do a window.location redirect.

However, when I press the Enter key, it apparently fires off the page validation. So I see the validation messages for a split second.

How can I tell the page not to fire any of the validation events when the focus is in that <input>?

2 Answers 2

5

If it's an <asp:Button>, just set the CausesValidation property to false. But, I suspect that it's not actually the button that's causing it - but the form submit that happens as a resul of the Enter key.

If that's the case, you can use the client side API and set Page_ValidationActive = false; when focus changes.

Sign up to request clarification or add additional context in comments.

Comments

0

Set ValidationGroup property of your validation controls. After that define ValidationGroup property to your button that you want to fire validation.

Also setting Causesvalidation property to false might help.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.