I have a form in which posts use ajax and reload the div at the bottom.
I need the text box to clear when the submit button is clicked.
<form name=goform action="" method=post> <textarea name=comment></textarea> <input type=submit value=submit> </form>
Add idfor textarea.
id
textarea
<textarea name='comment' id='comment'></textarea>
Connect to the sending process and add:
$('#comment').val('');
If you are not using jQuery (which is required for the solutions above), you can replace
$("#txtComment").val("");
from
document.getElementById("txtComment").value = "";
:
$("textarea[name=comment]").val("");
, , :
<form name=goform action="" method=post> <textarea id="txtComment" name="comment"></textarea> <input type=submit value=submit> </form>
<script> function testSubmit() { var x = document.forms["myForm"]["input1"]; var y = document.forms["myForm"]["input2"]; if (x.value === "") { alert(' fill!!'); return false; } Blockquote if(y.value === "") { alert('plz fill the!!'); return false; } return true; } function submitForm() { if (testSubmit()) { document.forms["myForm"].submit(); //first submit document.forms["myForm"].reset(); //and then reset the form values } } </script> <body> <form method="get" name="myForm"> First Name: <input type="text" name="input1"/> <br/> Last Name: <input type="text" name="input2"/> <br/> <input type="button" value="Submit" onclick="submitForm()"/> </form> </body>
Source: https://habr.com/ru/post/1724810/More articles:Download file from resource - androidResources for display systems in critical embedded security systems? - embeddedhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1724807/how-to-make-batch-remote-calls-to-database-or-service&usg=ALkJrhg2uEk7RW5R8a-R9uQnU_eZFstawQcan property / synthesize sqlite3 * database object? - sqlite'zip' in Erlang - erlangJQuery class selector starting with? - jqueryКак заставить компилятор Java рассказать мне, какой тип он имеет? - javaHow do I get a user to deal with a security warning when starting Access 2007? - vba.net - .netPerforming histogram alignment processing using C ++ opencv - c ++All Articles