没有双击,表格不起作用 [英] Form doesn't work without double click

查看:89
本文介绍了没有双击,表格不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jQuery中有一个表单函数的问题。它迫使我双击以提交表单。

I have a problem with a form function in jQuery. It forces me to double click in order to submit the form.

<script>  
function pin_login(forma) {
    jQuery("#form_" + forma).submit(function (e) {

        var value_pin = jQuery(".pin_" + forma).val();
    });
}
</script>

每次我双击它的作品,但它不起作用,当我单击时,它doesn不要提交表格。为了澄清,我希望它提交一个单一的点击,而不是双。

Every time I double click it works, but it doesn't work when I single click, it doesn't submit the form. To clarify, I want it to submit one a single click, not a double.

推荐答案

因为你调用 e.preventDefault()您的表单不应在第二次或第三次或第n次提交后返回。

Because you call e.preventDefault() your form should not return after second or third or nth clicking of submit.

如果您想提交您需要返回 true ,而不用像以下例子那样调用 e.preventDefault()

If you want to submit you need to return true without calling e.preventDefault() like in the example below.

$("form").submit(function() {
  if ( correct )
     return true;
  else {
     $("#error").text("Not valid!") ;
     return false;
  }
});

调用 e.preventDefault()或返回 false 会阻止将表单提交到服务器。

Calling e.preventDefault() or returning false will prevent submitting your form to the server.

现在,由于 e.preventDefault ()可以阻止表单提交,并声明表单执行了它,所以我声称你的代码不会被调用。你能复制粘贴吗?或者,也许你可以使用jsfiddle ...

Now, since e.preventDefault() prevents form submitting and you claim that your form does it, so I claim that your code from the example is never called. Can you copy paste more, please? Or maybe you can use jsfiddle...

这篇关于没有双击,表格不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆