JSFiddle - React, Tailwind, and code Playground

HTML

<form action="" method="post" id="cms" name="cms" enctype="multipart/form-data">
  <div class="input-group">
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="text" name="numberjpg" id="numberjpg" value='6'>
    <input type="text" name="numberpng" id="numberpng" value='6'>
    <input type="bottun" id="submit" name="submit" class="form-control" value="Submit" onclick="increase()">
  </div>
</form>

JavaScript

var x = document.getElementById('numberjpg')
     var stored = +localStorage.getItem('boxvalue');
     
     function increase() {
       x.value++;
       alert(document.getElementById('numberjpg').value);


       document.getElementById("numberjpg").setAttribute('value', document.getElementById('numberjpg').value);
     }
     
    
     if(stored) {
     x.value = stored; 
     }
    
     
window.onbeforeunload = function(){
  localStorage.setItem('boxvalue', document.getElementById('numberjpg').value);
};