Regular expressions would be one way. But be aware that many people enter phone numbers containing characters such as + / - ( ) or . - you need to account for that in some way. Or you can just remove everything that is not a number after they've entered it. Of course, "+491234567890" is not the same phone number as "491234567890", just in case you need to handle international numbers.