0
var limit = 5 * 60 * 1000

jQuery('#button').click(function() {

  var timer = setTimeout(disableMyButton, limit);

});

function disableMyButton() {
  $("#statusMsg").text("Disabling before page refresh");
  localStorage.setItem("isMyButtonDisabled", "true");
}

if (localStorage.getItem("isMyButtonDisabled") == "true") {
  $("#statusMsg").text("Disabling after page refresh");
  $('#employeeForm_OOBPIN').prop('disabled', true);
  window.clearTimeout(timer);
Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
  • Your code is incomplete – mplungjan Oct 04 '21 at 09:14
  • Move timer outside the click handler or make the function anonymous. `var timer` is only available to the click handler – mplungjan Oct 04 '21 at 09:15
  • Instead of storing "true" to the local storage, store the date when to hide/remove the content. Then on page load, read the time, and if it's in the future, start a timeout, otherwise just hide/remove the content. – Teemu Oct 04 '21 at 09:16
  • Java and JavaScript are different languages. Please don't tag Java when you mean JavaScript. – Federico klez Culloca Oct 04 '21 at 09:21

0 Answers0