i have an input field in django html file and a clear button and i want to clear the input filed when the clear button is pressed. how can it be done? do i need to know javascript for that or it can be done otherway?
<form>
<input type="text" id="textfield1" size="5">
<input type="text" id="textfield2" size="5">
<input type="reset" value="Reset">
</form>
i have an input field in django html file and a clear button and i want to clear the input filed when the clear button is pressed. how can it be done? do i need to know javascript for that or it can be done otherway?
<form>
<input type="text" id="textfield1" size="5">
<input type="text" id="textfield2" size="5">
<input type="reset" value="Reset">
</form>
i want to clear only one field not both
Share
Improve this question
asked Jun 27, 2017 at 2:46
NamelessNameless
5234 silver badges23 bronze badges
1
- 3 Without reloading the page, you will need to use some JavaScript to do this. – perfect5th Commented Jun 27, 2017 at 2:47
1 Answer
Reset to default 5This is just a simple thing :
<input type="button" value="Reset" id="resetBtn" onClick="this.form.reset()" />
Regarding to :
http://javascript-coder./javascript-form/javascript-reset-form.phtml