Hi This is my form...
<form id="frmer" class="form-inline" method="POST">
<input name="inp1" value="sda"/>
<button type="submit" class="btn btn-primary mr5">Search</button>
<button type="reset" class="btn btn-default" form="frmer">Reset</button>
</form>
I want to clear this default value also from text input when I click the reset button. But unfortunately it wouldn't happen. If someone know how to archive it or any workaround it would be a great help..
Hi This is my form...
<form id="frmer" class="form-inline" method="POST">
<input name="inp1" value="sda"/>
<button type="submit" class="btn btn-primary mr5">Search</button>
<button type="reset" class="btn btn-default" form="frmer">Reset</button>
</form>
I want to clear this default value also from text input when I click the reset button. But unfortunately it wouldn't happen. If someone know how to archive it or any workaround it would be a great help..
Share asked Nov 24, 2016 at 13:40 vimuthvimuth 5,68249 gold badges93 silver badges125 bronze badges 5- 3 @LuudJacobs — Why? – Quentin Commented Nov 24, 2016 at 13:43
- Depending on your usecase, I'd remend using placeholder instead of a default value. To clear the fields, you will need to use js – Tom M Commented Nov 24, 2016 at 13:44
-
1
Placeholder … or
<label>
, since the field doesn't have a<label>
at the moment, that is probably the real solution. – Quentin Commented Nov 24, 2016 at 13:45 - We cannot reset the value in HTML for reset button.. You must have to use jquery or javascript yo reset the form. – Sachin Sanchaniya Commented Nov 24, 2016 at 13:47
- @quentin, nevermind... brainfart – Luuuud Commented Nov 24, 2016 at 13:55
1 Answer
Reset to default 8Reset means "reset" not "blank". It is supposed to restore the default values.
If you want to blank the form, then you'll need JavaScript.
Loop over each control and test what type it is. Ignore buttons. Set the values of text, search, number, etc fields to ""
(an empty string). Set the checked
property of checkboxes to false
and so on.