I am using jQuery.validate plugin where I need to validate UK phone number with the following rule:
- It must start with 0
- It should be 10 or 11 digits with no characters allowed (whitespace allowed and not counted)
- Sequential or identical numbers (eg. 123456, 555555) ARE NOT ALLOWED
- Premium phone numbers not permitted (070x, 0845, 07624 etc.)
I have a current code which allows up to 12 digits. I need to fix it to 11.. Another fix which I need is to allow comma in it like the given example.. Currently comma is not allowed. Also I need to start it with 0
jQuery.validator.addMethod('phoneUK', function (phone_number, element) {
console.log(element);
return this.optional(element) || phone_number.length > 9 &&
phone_number.match(/^(((\+44)? ?(\(0\))? ?)|(0))( ?[0-9]{3,4}){3}$/);
}, 'Please specify a valid phone number');
Valid Phone No: 079 4135 9087 would be valid - so 10 or 11 digits - MUST start with 0 - can not start with 070 - can not start with 0845 - can not start with 07624 - can not be 10 or 11 same digits