- How to prevent input type="number" taking e
- Check if inputs are empty using jQuery
- Prevent SweetAlert to be closed on clicking outside the popup window
- jQuery select change show/hide div event
- Fire event only on image change
- How can I validate I have drawn something in jSignature panel or not?
- OTP verification 2 minutes count down timer
Java Script let timerOn = true; function timer(remaining) { var m = Math.floor(remaining / 60); var s = remaining % 60; m = m < 10 ? '0' + m : m; s = s < 10 ? '0' + s : s; document.getElementById('timer').innerHTML = m + ':' + s; remaining -= 1; if(remaining >= 0 && timerOn) { setTimeout(function() { timer(remaining); }, 1000); return; } if(!timerOn) { // Do validate stuff here return; } // Do timeout stuff here alert('Timeout for otp'); } // Then Call the function of Timer // timer(120); HTML <input type="text" name="otp" placeholer="Enter your otp"/> <div>Time left = <span id="timer"></span></div>
Comments
Post a Comment