【问题标题】:How to make the form submit with normal button?如何使用普通按钮提交表单?
【发布时间】:2014-07-17 11:29:14
【问题描述】:

这是我使用的代码。 通过点击功能,我对控制器进行了 POST 操作..

$('#btn1').click(function (e) {

    $.post($('#frmLogin').attr('action'), $('#frmLogin').serialize(), function (data) {

    });
});


@using (Html.BeginForm("Login", "Login", new { Model }, FormMethod.Post, new { id = "frmLogin" }))
{ 
    <input type="button" id="btn1"/>
});

【问题讨论】:

    标签: forms button post serialization submit


    【解决方案1】:

    点击普通按钮时调用此函数

        function form_submit()
        {
                document.getElementById('formID').submit();
        }
    or use this jquery
    
    
    
     $( "#btn1" ).click(function() {
      $( "#frmLogin" ).submit();
       });
    

    【讨论】:

    • 点击 ENTER 键会提交表单吗?
    • 它不起作用..我得到了解决方案..我触发了一个 trigegr.. $("#txtPassword").keyup(function (event) { if (event.keyCode == 13 ) { $("#btnSubmit").trigger("click"); } });
    猜你喜欢
    • 1970-01-01
    • 2012-07-13
    • 1970-01-01
    • 2017-12-28
    • 2011-05-16
    • 1970-01-01
    • 2021-08-11
    • 2011-12-13
    • 1970-01-01
    相关资源
    最近更新 更多