commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / bower_components / jquery-validation / src / additional / phoneUK.js
1 /* For UK phone functions, do the following server side processing:
2 * Compare original input with this RegEx pattern:
3 * ^\(?(?:(?:00\)?[\s\-]?\(?|\+)(44)\)?[\s\-]?\(?(?:0\)?[\s\-]?\(?)?|0)([1-9]\d{1,4}\)?[\s\d\-]+)$
4 * Extract $1 and set $prefix to '+44<space>' if $1 is '44', otherwise set $prefix to '0'
5 * Extract $2 and remove hyphens, spaces and parentheses. Phone number is combined $prefix and $2.
6 * A number of very detailed GB telephone number RegEx patterns can also be found at:
7 * http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
8 */
9 $.validator.addMethod("phoneUK", function(phone_number, element) {
10 phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
11 return this.optional(element) || phone_number.length > 9 &&
12 phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/);
13 }, "Please specify a valid phone number");