I have a form which posts using ajax and reloads the div underneath.
I need the textbox to clear when the submit button is pressed.
<form name=goform action="" method=post>
<textarea name=comment></textarea>
<input type=submit value=submit>
</form>
Add an id
for the textarea
.
<textarea name='comment' id='comment'></textarea>
Hook into the submit process and add:
$('#comment').val('');
If you're not using jQuery (which is required for the solutions given above) you can replace the
$("#txtComment").val("");
with
document.getElementById("txtComment").value = "";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With