是否在单击提交后删除表单输入字段数据


Remove the form input fields data after click on submit?

hi我正在使用一个表单供用户在目标为_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>

使用此重置表单数据

$('form').get(0).reset();
$(document).ready(function(){
  $('form_name').submit(function(){
    $('input[type="text"]').val('');
  });
});

您可以使用submit按钮上的jquerytext field的值设置为null,单击

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

编辑:

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

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

但它会满足你的需求。