From 393d1ae11b0bf37c87f8b2b84e009284cc471c35 Mon Sep 17 00:00:00 2001 From: khanshanawaz10 Date: Mon, 18 Nov 2024 13:20:12 +0530 Subject: [PATCH 1/2] handle validation msg --- campaign.html | 75 ++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/campaign.html b/campaign.html index 41d726b..317e384 100644 --- a/campaign.html +++ b/campaign.html @@ -1385,33 +1385,35 @@ input[type=number]::-webkit-outer-spin-button { // 2 minutes in seconds // let timeLeft = 120; // 2 minutes in seconds - let 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 TimerClock() { + + var timerId; + function startTimer() { + let canResend = true; + 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; @@ -1453,14 +1455,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' @@ -1469,6 +1471,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(); @@ -1804,9 +1807,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(); From f3b5b6cbd12ed4be2750a8494c50c74536f4af87 Mon Sep 17 00:00:00 2001 From: khanshanawaz10 Date: Mon, 18 Nov 2024 13:30:29 +0530 Subject: [PATCH 2/2] handle resend OTP --- campaign.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/campaign.html b/campaign.html index 317e384..53ee0f0 100644 --- a/campaign.html +++ b/campaign.html @@ -1388,8 +1388,8 @@ input[type=number]::-webkit-outer-spin-button { // function TimerClock() { var timerId; + let canResend = true; function startTimer() { - let canResend = true; let timeLeft = 120; timerId = setInterval(() => { if (timeLeft <= 0) {