Simple UK Phone Number Validation
This is a simple solution which should help a lot with accidental errors, but it’s still very easy for someone to enter a fake number if they want to. The first line of code removes anything thats not a number from a submitted post variable called ‘phone’. The second line checks the number begins with a 0, followed by 1-9 (‘00′ is not allowed as it’s the UK dialling prefix for international calls), followed by 8 or 9 other digits. The example below works with PHP 5.2.0 & above.
- echo 'Please enter your phone number correctly';
- }
0 Comments