Languages
[Edit]
EN

HTML - restore input default value

0 points
Created by:
Eshaal-Wilkinson
384

In this article, we would like to show you how to restore input default value in HTML.

Quick solution:

// ONLINE-RUNNER:browser;

<form>
  <input type="number" name="input-name" value="0" />
  <input type="reset" value="Restore default" />
</form>

 

Practical example

To restore the input element's default value, we need to:

  1. set the default value using the input element's value attribute,
  2. create reset input that restores the default value of all inputs in the form.
// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <form>
    <label>
      <span>Username:</span>
      <input type="text" name="username" value="guest" />
    </label>
    <input type="reset" value="Restore default" />
  </form>
</body>
</html>

References

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join