<input id="myinput" /> <script> var input = document.getElementById('myinput'); input.value = localStorage.getItem('dataForMyInput') || ''; input.oninput = function() { localStorage.setItem('dataForMyInput', input.value); } </script>