تماس با ما
راه های ارتباطی ما
021-56654715
09305768693
09913933152
ایمیل ما
Nikolaelectric7@gmail.com
Nikolaelectric2000@gmail.com
پیج اینستاگرام
<style>
/* بخش کد تایید در ابتدا کاملاً مخفی باشد */
#otp-area {
display: none;
margin-top: 15px;
padding: 15px;
background: #fdfdfd;
border-radius: 10px;
border: 1px dashed #28a745;
}
.otp-container {
display: flex;
justify-content: center;
gap: 8px;
direction: ltr;
}
.otp-box {
width: 40px;
height: 50px;
text-align: center;
font-size: 20px;
font-weight: bold;
border: 2px solid #28a745;
border-radius: 8px;
background: #fff;
}
.timer-section {
text-align: center;
margin-top: 10px;
font-size: 13px;
color: #666;
}
</style>
<div id="otp-area">
<div class="otp-container">
<input type="text" class="otp-box" maxlength="1" inputmode="numeric">
<input type="text" class="otp-box" maxlength="1" inputmode="numeric">
<input type="text" class="otp-box" maxlength="1" inputmode="numeric">
<input type="text" class="otp-box" maxlength="1" inputmode="numeric">
<input type="text" class="otp-box" maxlength="1" inputmode="numeric">
<input type="text" class="otp-box" maxlength="1" inputmode="numeric">
</div>
<div class="timer-section">
<span>زمان باقیمانده: </span>
<span id="countdown" style="color: #d9534f; font-weight: bold;">02:00</span>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const otpArea = document.getElementById('otp-area');
const inputs = document.querySelectorAll('.otp-box');
const countdownEl = document.getElementById('countdown');
let timeLeft = 120;
// ۱. گوش دادن به دکمه سبز المنتور (ارسال)
// نکته: المنتور بعد از ارسال موفق فرم، رویداد submit_success را اجرا میکند
jQuery(document).on('submit_success', function() {
otpArea.style.display = 'block'; // نمایش بخش کد
startTimer(); // شروع تایمر
inputs[0].focus(); // فوکوس روی اولین کادر
});
// ۲. جابجایی بین کادرها
inputs.forEach((input, index) => {
input.addEventListener('input', (e) => {
if (e.target.value && index < 5) inputs[index + 1].focus();
// بررسی خودکار: اگر هر ۶ کادر پر شد، عملیات ثبت انجام شود
checkAndSubmit();
});
input.addEventListener('keydown', (e) => {
if (e.key === 'Backspace' && !e.target.value && index > 0) inputs[index - 1].focus();
});
});
// ۳. تابع بررسی و ثبت خودکار
function checkAndSubmit() {
let code = "";
inputs.forEach(input => code += input.value);
if (code.length === 6) {
console.log("کد کامل شد: " + code);
// در اینجا عملیات نهایی ثبت نام ووکامرس انجام میشود
// میتوانید دکمه "ثبت نام" اصلی را به صورت مجازی کلیک کنید
const finalBtn = document.querySelector('.elementor-button-wrapper .elementor-button'); // دکمه زرد شما
if(finalBtn) finalBtn.click();
}
}
// ۴. منطق تایمر
function startTimer() {
const timerId = setInterval(() => {
let min = Math.floor(timeLeft / 60);
let sec = timeLeft % 60;
countdownEl.innerHTML = `0${min}:${sec < 10 ? '0'+sec : sec}`;
if (timeLeft <= 0) clearInterval(timerId);
timeLeft--;
}, 1000);
}
});
</script>