navaqeel
06-07-2007, 12:13 AM
Hi everyone:
Just wondering if anyone can help me with this. I've created an HTML form and written a javascript that tests to make sure users don't leave any fields blank when submitting the form. One of the fields on the form is the phone_number. I want to make sure that users only enter the numeric value in this field. If for example, they enter some letters in the phone_number field then javascript should prompt them to only enter the numbers. How would I do this? Here's a code I am using to make sure fields are NOT left empty:
if (formObj.phone_number.value == "") {
window.alert("Please enter a valid phone number along with the area code");
formObj.phone_number.focus();
return false;
}
Thanks for your help and cooperation in advance.
Just wondering if anyone can help me with this. I've created an HTML form and written a javascript that tests to make sure users don't leave any fields blank when submitting the form. One of the fields on the form is the phone_number. I want to make sure that users only enter the numeric value in this field. If for example, they enter some letters in the phone_number field then javascript should prompt them to only enter the numbers. How would I do this? Here's a code I am using to make sure fields are NOT left empty:
if (formObj.phone_number.value == "") {
window.alert("Please enter a valid phone number along with the area code");
formObj.phone_number.focus();
return false;
}
Thanks for your help and cooperation in advance.