I think you need to save the phone number in your database as text.
Check it out: Phone number data type not recognized as number
The reason it was working the way you have it is because when you say formatted as: it changes the number to a text type.