I use the following code to reset form fields.
document.getElementById("form1").reset();
He does not work. I also tried using JQuery
. Even jQuery also does not work.
$("#reset").click(function(){
$('form1')[0].reset();
});
My html code
<form name="form1" id="form1" method="post">
<h3>Personal Information</h3>
<h4>Name</h4>
<input type="text" id="fname" name="fname" maxlength=50 size=11/>
<input type="text" id="mname" name="mname" maxlength=15 size=8/>
<input type="text" id="lname" name="lname" maxlength=50 size=11/>
<input type="button" id="reset" value="Reset" onclick="Reset()"/>
</form>
I follow W3Schools . Here is my fiddle . Could you explain the mistake?
source
share