繁体   English   中英

单击提交后删除表单输入字段数据?

[英]Remove the form input fields data after click on submit?

您好,我正在使用一个表单供用户在网站上订阅,目标是_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>

有什么建议么???

使自动完成-关闭

尝试这个

<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>

您可以在单击submit按钮时使用jquery submit text field值设置为null

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

编辑:

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

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

但这将满足您的需求。

$(document).ready(function(){

  $('form_name').submit(function(){

    $('input[type="text"]').val('');

  });

});

使用此重置表单数据

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM