document.addEventListener('DOMContentLoaded', function() { const phoneInput = document.getElementById('phone'); const submitButton = document.querySelector('.loginnn'); function validatePhone(phone) { // Ensure phone number contains only digits, and is at least 8 digits long const regex = /^\d{8,18}$/; return regex.test(phone); } function validateForm() { const phoneValue = phoneInput.value.trim(); const phoneValid = validatePhone(phoneValue); if (phoneValid) { submitButton.disabled = false; submitButton.style.backgroundColor = '#004877'; // Normal color (Bootstrap primary button color) } else { submitButton.disabled = true; submitButton.style.backgroundColor = 'rgb(19, 168, 218)'; // Disabled color } } phoneInput.addEventListener('input', function() { this.value = this.value.replace(/\D/g, ''); // Removes non-digit characters validateForm(); }); // Initial validation check validateForm(); });