简体   繁体   中英

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

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

$("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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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