【问题标题】:Remove the form input fields data after click on submit?单击提交后删除表单输入字段数据?
【发布时间】:2014-05-22 11:23:57
【问题描述】:

您好,我在网站上使用用户订阅表格,目标是 _new。 当我单击提交消息显示在新窗口上但前一个窗口仍保存数据的提交按钮时。 提交后如何删除输入字段数据。

<form target="_new" action="samplepage.php"  method="post">
<input type="text" name="inputtxt1" />
<input type="text" name="inputtxt2"  />
<input type="submit" value="submit"  />
</form>

有什么建议吗???

【问题讨论】:

    标签: php jquery html


    【解决方案1】:

    关闭自动完成功能

    试试这个

    <form target="_new" action="samplepage.php"  method="post" autocomplete="off">
    <input type="text" name="inputtxt1" />
    <input type="text" name="inputtxt2"  />
    <input type="submit" value="submit"  />
    </form>
    

    【讨论】:

    • 是的,我同意先生。 @Big Chris .. 但它是解决这个问题的简单方法。
    【解决方案2】:

    使用 this 重置表单数据

    $('form').get(0).reset();
    

    【讨论】:

      【解决方案3】:
      $(document).ready(function(){
      
        $('form_name').submit(function(){
      
          $('input[type="text"]').val('');
      
        });
      
      });
      

      【讨论】:

        【解决方案4】:

        您可以在点击submit 按钮时使用jquerytext field 的值设置为null

        $("input[type=submit]").click(function()
            {
                $("input[type=text]").val('');
            });
        

        编辑:

        我不知道这是不是一个好方法,使用blur而不是click事件

        $("input[type=submit]").blur(function()
            {
                $("input[type=text]").val('');
            });
        

        但它会满足你的需要。

        【讨论】:

        • 我们必须在表单提交后将值设为空
        • k,我试试……你能用ajax吗??
        • 谢谢我在你的第一个答案中添加了 jquery 时间延迟,然后它工作正常
        猜你喜欢
        • 1970-01-01
        • 2019-04-21
        • 1970-01-01
        • 1970-01-01
        • 2022-07-08
        • 2020-07-14
        • 1970-01-01
        • 2021-09-10
        • 1970-01-01
        相关资源
        最近更新 更多