|
|
@ -545,15 +545,16 @@ |
|
|
|
const mobileInput = document.getElementById('mobile'); |
|
|
|
const mobileError = document.getElementById('mobile-error'); |
|
|
|
|
|
|
|
// Handle input events (input and keydown) |
|
|
|
|
|
|
|
|
|
|
|
mobileInput.addEventListener('input', validateMobileNumber); |
|
|
|
mobileInput.addEventListener('keydown', validateMobileNumber); |
|
|
|
mobileInput.addEventListener('keyup', validateMobileNumber); |
|
|
|
mobileInput.addEventListener('click', validateMobileNumber); |
|
|
|
|
|
|
|
function validateMobileNumber(e) { |
|
|
|
const inputValue = e.target.value; |
|
|
|
if (e.type === 'keydown' && inputValue === '+44') { |
|
|
|
e.target.value = ''; |
|
|
|
} |
|
|
|
|
|
|
|
// Check if the current value is the default value |
|
|
|
if (inputValue === '+44') { |
|
|
|
mobileError.textContent = 'Invalid Mobile Number'; |
|
|
@ -562,11 +563,44 @@ |
|
|
|
mobileError.textContent = ''; |
|
|
|
} |
|
|
|
|
|
|
|
// Handle 'keydown' event |
|
|
|
if (e.type === 'keydown' && inputValue === '+44') { |
|
|
|
e.target.value = ''; |
|
|
|
} |
|
|
|
|
|
|
|
// Handle 'click' event |
|
|
|
if (e.type === 'click' && inputValue === '+44') { |
|
|
|
e.target.value = ''; |
|
|
|
} |
|
|
|
|
|
|
|
// Format the input as a phone number with the "+44" prefix |
|
|
|
const x = inputValue.replace(/\D/g, '').match(/(\d{0,2})(\d{0,3})(\d{0,3})(\d{0,2})(\d{0,2})/); |
|
|
|
e.target.value = '+44' + x[2] + '' + x[3] + '' + x[4] + '' + x[5]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Handle input events (input and keydown) |
|
|
|
// mobileInput.addEventListener('input', validateMobileNumber); |
|
|
|
// mobileInput.addEventListener('keydown', validateMobileNumber); |
|
|
|
|
|
|
|
// function validateMobileNumber(e) { |
|
|
|
// const inputValue = e.target.value; |
|
|
|
// if (e.type === 'keydown' && inputValue === '+44') { |
|
|
|
// e.target.value = ''; |
|
|
|
// } |
|
|
|
// // Check if the current value is the default value |
|
|
|
// if (inputValue === '+44') { |
|
|
|
// mobileError.textContent = 'Invalid Mobile Number'; |
|
|
|
// } else { |
|
|
|
// // Reset the error message |
|
|
|
// mobileError.textContent = ''; |
|
|
|
// } |
|
|
|
|
|
|
|
// // Format the input as a phone number with the "+44" prefix |
|
|
|
// const x = inputValue.replace(/\D/g, '').match(/(\d{0,2})(\d{0,3})(\d{0,3})(\d{0,2})(\d{0,2})/); |
|
|
|
// e.target.value = '+44' + x[2] + '' + x[3] + '' + x[4] + '' + x[5]; |
|
|
|
// } |
|
|
|
|
|
|
|
// Handle form submission |
|
|
|
document.querySelector('form').addEventListener('submit', function (event) { |
|
|
|
// Check if the mobile number is still the default value |
|
|
|