Reset a form except one field with Javascript

forms, javascript

Solution

Copy its value to a variable. Reset the form. Reassign the variable back to the value.

Problem

For some reason, I need to reset a form but I want one field to remain unchanged. This following code clears all the fields but I would like to keep the first one unchanged. ``` <form id="myForm"> <input id="01" type="text"/> <input id="02" type="text"/> <input id="03" type="text"/> <input id="04" type="text"/> </form> <button onclick="document.getElementById('myForm').reset()">Reset</button> ``` If possible, I would like to avoid jQuery.

Original source