how to prevent kendo validation on pressing enter key ?

3 posts, 0 answers
  1. frederic
    frederic avatar
    8 posts
    Member since:
    Apr 2015

    Posted 01 Jun 2015 Link to this post

    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. Plamen Lazarov
    Admin
    Plamen Lazarov avatar
    135 posts

    Posted 03 Jun 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. frederic
    frederic avatar
    8 posts
    Member since:
    Apr 2015

    Posted 04 Jun 2015 in reply to Plamen Lazarov Link to this post

    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.

Back to Top