mrpatg mrpatg - 6 months ago 19
Javascript Question

clear textbox after form submit

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>

Answer

Add an id for the textarea.

<textarea name='comment' id='comment'></textarea>

Hook into the submit process and add:

$('#comment').val('');