phone number



using a form field a customer is going to enter his phone number in this format 1234567890.

can i have php "when the form field loses focus" to change this number into (123)456-7890

or do i have to use javascript i know it's possible in javascipt by using the onBlur=myphonescript command
PHP is a server-side language, and cannot do anything on the client side after the page has loaded in the user's browser. In other words, use JavaScript. It's not terribly complicated. Though I'm not sure why you'd want to do it (why not just wait until the user submits the form and make the change internally?).
well im gonna have a lot of users inputting at the same time and i wanted to put the least amount of strain on my server and if i can do it client sider rather than server side it'll help a little
But if you're worried about having accurate data, you're going to have to validate the phone numbers again on the server side anyway, since anybody with JavaScript turned off could enter an arbitrarily-formatted value. Since you're probably doing form validation anyway (right?), doing this on the server side isn't going to make much of a difference.
on the process page after the form you could put this?

$p1 = substr($number, 1, 3);
$p2 = substr($number, 4, 6);
$p3 = substr($number, 7,10);

$finalnumber = "(" . $p1 . ")" . $p2 . "-" . $p3;
nathanwebb6 said:
o wait, you wanted it when you lose focus. well u could still use that method if it will work for your needs