简体   繁体   English

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

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

hi i am using a form for users subscription on the website with target is _new. 您好,我正在使用一个表单供用户在网站上订阅,目标是_new。 when i click on the submit button that the submitting message shows on the new window but the previous window still holding the data. 当我单击提交按钮时,提交消息将显示在新窗口中,但先前的窗口仍保存数据。 How to remove input fields data after submitting. 提交后如何删除输入字段数据。

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

Any suggestions??? 有什么建议么???

Make the autocomplete - off 使自动完成-关闭

try this 尝试这个

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

You can set value to null for text field using jquery on submit button click 您可以在单击submit按钮时使用jquery submit text field值设置为null

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

EDIT: 编辑:

I don't know is this a good approach, use blur instead of click event 我不知道这是一个好方法,请使用blur而不是click事件

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

But it will meet your need. 但这将满足您的需求。

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