...

View Full Version : Phone Number Display



bubble00000
06-22-2010, 02:16 PM
Just wondering what the code is for a phone number to be displayed
nn-nnnnnnnn

for example: 67 43289482

current code is


var pn = document.contact_form.phonenum.value;
if ((pn.length != 10) || (/[^0-9]/g.test(pn))) { // 10-digit phone number
alert ( "Please fill in your 10-digit telephone number" );
return false;
}

vwphillips
06-22-2010, 02:30 PM
http://www.vicsjavascripts.org.uk/FormCompendium/FormatNumber.htm

bubble00000
06-22-2010, 02:42 PM
fixed it just


{
if(document.contact_form.phonenum.value.search(/\d{2} \d{8}/)==-1)
{
alert("The phone number you entered is not valid.\r\nPlease enter a phone number with the format xx xxxxxxx");
return false;
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum