admin管理员组

文章数量:1289875

I need the form to be cleared after the form has been submitted. TIA

<script type="text/javascript"> 
$(document).ready(function() { 
$('#msgform').ajaxForm(function (data, textStatus) {
$("#msgresults").show();
$('#msgresults').append(data);
});
}); 
</script>

I need the form to be cleared after the form has been submitted. TIA

<script type="text/javascript"> 
$(document).ready(function() { 
$('#msgform').ajaxForm(function (data, textStatus) {
$("#msgresults").show();
$('#msgresults').append(data);
});
}); 
</script>
Share Improve this question asked Jun 25, 2011 at 22:40 PatriotecPatriotec 3991 gold badge6 silver badges21 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

You could try this:

$('#msgform')[0].reset();

You could attach a .submit() listener in which you set the contents of whatever form elements.

Somewhat like

$('#msgform').submit(function () {
  $(this).children('input[type=text]').val('');
});

Here's the correct code. I found a solution to clear the textarea field with the id of 'msgtextarea'

<script type="text/javascript"> 
  $(document).ready(function() { 
      $('#msgform').ajaxForm(function (data, textStatus) {
            $("#msgresults").show();
            $('#msgresults').append(data);
            $("#msgtextarea").val("")
      });
  }); 
</script>

本文标签: javascriptJquery ajaxForm clear form after form submissionStack Overflow