This is a migrated thread and some comments may be shown as answers.

how to prevent kendo validation on pressing enter key ?

2 Answers 527 Views
Validation
This is a migrated thread and some comments may be shown as answers.
frederic
Top achievements
Rank 1
frederic asked on 01 Jun 2015, 03:30 PM

Hi,

Using a kendo ui validator on a form, it seems that pressing the enter key in a text field cause the validate() method to run.

How to prevent this behavior ?

 

Thank you.

 

Laurent.

2 Answers, 1 is accepted

Sort by
0
Plamen Lazarov
Telerik team
answered on 03 Jun 2015, 12:52 PM

Hi Laurent,

The described behavior is expected since pressing the Enter key will fire the form's submit event. As a workaround the keypress event handler could be used in order to detect if the Enter key has been pressed and prevent the default actions if it is:

$("#ticketsForm").keypress(function(e){
  if(e.keyCode === 13){
    e.preventDefault();
  }
});

I have prepared a simple demo illustrating this approach. Please note that using this approach will not allow you to submit the form by pressing the Enter key. 

Regards,
Plamen Lazarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
frederic
Top achievements
Rank 1
answered on 04 Jun 2015, 08:30 AM

hi Plamen,

Thank you for your prompt response. Finaly, I found my way by using the "novalidate" attribute on form tag + binding submit event on form to false. 

 F.

Tags
Validation
Asked by
frederic
Top achievements
Rank 1
Answers by
Plamen Lazarov
Telerik team
frederic
Top achievements
Rank 1
Share this question
or