loading page
let recaptchaVerifier; function sendOTP() { const phone = document.getElementById("phone").value.trim(); const status = document.getElementById("status"); if (!phone.startsWith("+")) { status.textContent = "Please include country code. Example: +91 9876543210"; return; } if (!recaptchaVerifier) { recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container', { size: 'invisible' }); recaptchaVerifier.render(); } firebase.auth().signInWithPhoneNumber(phone, recaptchaVerifier) .then((confirmationResult) => { window.confirmationResult = confirmationResult; document.getElementById("otp-section").style.display = "block"; status.textContent = "OTP sent. Please check your SMS."; }) .catch((error) => { status.textContent = "Error: " + error.message; }); } function verifyOTP() { const code = document.getElementById("otp").value.trim(); const status = document.getElementById("status"); if (!window.confirmationResult) { status.textContent = "Please send OTP first."; return; } window.confirmationResult.confirm(code) .then((result) => { status.textContent = "Login successful!"; }) .catch((error) => { status.textContent = "Invalid OTP. Try again."; }); }