you should be using both server side and client side validation on the form, the client side validation will reformat the phone number, the server validation will make sure a proper phone number is entered.
this seams to be the way your page is working at the moment, I'm not sure I understand what the issue is.