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