EN
HTML - restore input default value
0 points
In this article, we would like to show you how to restore input default value in HTML.
Quick solution:
xxxxxxxxxx
1
<form>
2
<input type="number" name="input-name" value="0" />
3
<input type="reset" value="Restore default" />
4
</form>
To restore the input
element's default value, we need to:
- set the default value using the
input
element's value attribute, - create reset input that restores the default value of all inputs in the
form
.
xxxxxxxxxx
1
2
<html>
3
<body>
4
<form>
5
<label>
6
<span>Username:</span>
7
<input type="text" name="username" value="guest" />
8
</label>
9
<input type="reset" value="Restore default" />
10
</form>
11
</body>
12
</html>