开发者

Detect a page submit in jQuery

开发者 https://www.devze.com 2022-12-15 10:47 出处:网络
I am currently working with reading data from a USB card rea开发者_Python百科der and it sends a page submit command along with the card track data.

I am currently working with reading data from a USB card rea开发者_Python百科der and it sends a page submit command along with the card track data.

Is there a way for me to detect a page submit command and can I programmatically disable the submit command?


In HTML it's super-easy:

<form onsubmit="return false">

You also do it via code in JQuery like so:

$('#form_id').submit(function(e) {
  e.preventDefault();
  return false;
});


Handle the form's submit event and return false if you want it to be canceled.

For example:

$('form').submit(function() {
    //Do something
    return !hadErrors;
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号