diff --git a/campaign.html b/campaign.html index ec47971..418912d 100644 --- a/campaign.html +++ b/campaign.html @@ -1428,33 +1428,35 @@ input[type=number]::-webkit-outer-spin-button { // 2 minutes in seconds // let timeLeft = 120; // 2 minutes in seconds - let timerId; + // function TimerClock() { + + var timerId; let canResend = true; - let timeLeft = 120; - - function startTimer() { - timerId = setInterval(() => { - if (timeLeft <= 0) { - clearInterval(timerId); - timerDisplay.textContent = "Code expired"; - timerDisplay.classList.add('expired'); - // inputs.forEach(input => input.disabled = true); - $("#otp-not-found").css("display","block") - // canResend = false; - } else { - const minutes = Math.floor(timeLeft / 60); - const seconds = timeLeft % 60; - timerDisplay.textContent = `(${minutes}:${seconds.toString().padStart(2, '0')})`; - timeLeft--; - } - }, 1000); - } + function startTimer() { + let timeLeft = 120; + timerId = setInterval(() => { + if (timeLeft <= 0) { + clearInterval(timerId); + timerDisplay.textContent = "Code expired"; + timerDisplay.classList.add('expired'); + // inputs.forEach(input => input.disabled = true); + $("#otp-not-found").css("display","block") + // canResend = false; + } else { + const minutes = Math.floor(timeLeft / 60); + const seconds = timeLeft % 60; + timerDisplay.textContent = `(${minutes}:${seconds.toString().padStart(2, '0')})`; + timeLeft--; + } + }, 1000); + } + // } function resendOTP() { if (canResend) { // alert("New OTP sent!"); - timeLeft = 120; + let timeLeft = 120; inputs.forEach(input => { input.value = ''; input.disabled = false; @@ -1496,14 +1498,14 @@ input[type=number]::-webkit-outer-spin-button { function verifyOTP() { const otp = Array.from(inputs).map(input => input.value).join(''); if (otp.length === 6) { - if (timeLeft > 0) { - handleVerifyOTP(otp) - // alert(`Verifying OTP: ${otp}`); - } else { - const invalidMsg = document.getElementById('invalid-otp-msg'); - invalidMsg.textContent = 'OTP has expired. Please request a new one.' - // alert('OTP has expired. Please request a new one.'); - } + handleVerifyOTP(otp) + // if (timeLeft > 0) { + // // alert(`Verifying OTP: ${otp}`); + // } else { + // const invalidMsg = document.getElementById('invalid-otp-msg'); + // invalidMsg.textContent = 'OTP has expired. Please request a new one.' + // // alert('OTP has expired. Please request a new one.'); + // } } else { const invalidMsg = document.getElementById('invalid-otp-msg'); invalidMsg.textContent = 'Please enter a 6-digit OTP' @@ -1512,6 +1514,7 @@ input[type=number]::-webkit-outer-spin-button { } // } function sendOTP() { + // TimerClock() var name = $("#input-Name").val(); var phoneno = $("#input-PhoneNo").val(); var email = $("#input-Email").val(); @@ -1847,9 +1850,15 @@ input[type=number]::-webkit-outer-spin-button { }) } function handleClosePopUp() { - $(document).ready(function () { - $(".closeDialog").trigger("click"); - }); + // $(document).ready(function () { + const invalidMsg = document.getElementById('invalid-otp-msg'); + invalidMsg.textContent = '' + inputs.forEach(input => { + input.value = ''; + }); + clearInterval(timerId); + $(".closeDialog").trigger("click"); + // }); } function handlehideARN() { $('.arn-class').toggle();