The code for this is something your web team may want to consider using if they are designing a GET form for your website.
<script type='text/javascript'>
function FormatPhone(phone)
{
var key;
if (window.event)
key = window.event.keyCode;
if(key==37) //LEFT_ARROW
return;
if(key==39) //RIGHT_ARROW
return;
if(key==8) //BACK_SPACE
return;
if(key==09) //TAB
return;
if(key==16) //CTRL_TAB
return;
if (phone.value == '(' )
return;
var digits = phone.value.replace(/[^0-9]/ig, '');
if (!digits) {
phone.value = '';
return;
}
if (digits.length == 3) {
phone.value = '(' + digits.substring(0, 3) + ') ';
return;
}
if (digits.length == 4) {
phone.value = '(' + digits.substring(0, 3) + ') ' +
digits.substring(3, 4);
return;
}
if (digits.length == 5) {
phone.value = '(' + digits.substring(0, 3) + ') ' +
digits.substring(3, 5);
return;
}
if (digits.length == 6) {
phone.value = '(' + digits.substring(0, 3) + ') ' +
digits.substring(3, 6) + '-';
return;
}
if (digits.length == 7) {
phone.value = '(' + digits.substring(0, 3) + ') ' +
digits.substring(3, 6) + '-' +
digits.substring(6, 7);
return;
}
if (digits.length == 8) {
phone.value = '(' + digits.substring(0, 3) + ') ' +
digits.substring(3, 6) + '-' +
digits.substring(6, 8);
return;
}
if (digits.length == 9) {
phone.value = '(' + digits.substring(0, 3) + ') ' +
digits.substring(3, 6) + '-' +
digits.substring(6, 9);
return;
}
if (digits.length == 10) {
phone.value = '(' + digits.substring(0, 3) + ') ' +
digits.substring(3, 6) + '-' +
digits.substring(6, 10);
}
else
{
phone.value = '(' + digits;
}
}
</script>
A Validator on the form's onsubmit event. Below is the an example ONLY to show the onsubmit.