views:

554

answers:

2

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>?

A: 

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.

Canavar
+3  A: 

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.

Mark Brackett