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