I want to hide submit button a number of times in a day.
Below code sometime works, sometime not works. Yesterday code worked but today code not working. I am unable to understand where the problem is.
<script>
window.addEventListener("load", function() {
// Check time and update the button's state every second.
setInterval(updateSubmitButtonState, 1000);
}, false);
function updateSubmitButtonState() {
var timezone = "Asia/Calcutta";
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var t =currentTime.getHours() + ":" + currentTime.getMinutes();
if (t >= '10:00' && t <= '10:20' ||
t >= '11:00' && t <= '11:20' ||
t >= '13:00' && t <= '13:20' ||
t >= '15:15' && t <= '15:25' ||
t >= '17:30' && t <= '17:40' ||
t >= '19:00' && t <= '19:10' ||
t >= '20:30' && t <= '20:40' ) {
$("#submit").css("display", "none");
} else {
$("#submit").css("display", "block");
}
}
</script>
<input type="submit" id="submit" name="submit">