jquery - Javascript Block Form action on "enter" submit -


i'm working in laravel framework, , have form:

view

{!! form::open() !!}  <input type="text" name="puntata" id="puntata">  <button id="registro" type="button" class="btn-primary">punta</button> {!! form::close()!!} 

js

var button = d.getelementbyid('registro');    function puntata() {       ....my code...    } var submit = button.onclick = puntata; 

when insert value in input "puntata" , click on button "registro" call function js, work well.

but if insert value in input "puntata" , "enter" in keyboard submit form without call function javascript. how can block this?

i on event "enter" call function puntata() , not submit form.

thank help!

you should use jquery's keydown this:

$(document).ready(function() {    $(window).keydown(function(event){      if(event.keycode == 13) { // -- 13 enter key       event.preventdefault();       return false;     }    });  }); 

hope helps!


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -