If you look at the console-log (F12, then console tab while you're viewing the page), you'll see that the statement
is resulting in the phone variable being null (i.e. no element with id="email-address"). Of course, you'll eventually change this statement toCode:var phone = document.getElementById('email-address').value;
but it, too, will fail.Code:var phone = document.getElementById('telephone').value;
The issue is that you're setting that variable before the page has been fully loaded so the HTML element is not available. Perhaps you'd want to move the following code block to the top of the check_form function:
Code:var phone = document.getElementById('telephone').value; phone.value = phone.value.replace(/\D/g,""); if (phone.value.toString().length == 10){ document.getElementById('telephone').value = phone.value; }


Reply With Quote
