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 / phoneUS.js
1 /**
2 * matches US phone number format
3 *
4 * where the area code may not start with 1 and the prefix may not start with 1
5 * allows '-' or ' ' as a separator and allows parens around area code
6 * some people may want to put a '1' in front of their number
7 *
8 * 1(212)-999-2345 or
9 * 212 999 2344 or
10 * 212-999-0983
11 *
12 * but not
13 * 111-123-5434
14 * and not
15 * 212 123 4567
16 */
17 $.validator.addMethod("phoneUS", function(phone_number, element) {
18 phone_number = phone_number.replace(/\s+/g, "");
19 return this.optional(element) || phone_number.length > 9 &&
20 phone_number.match(/^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]([02-9]\d|1[02-9])-?\d{4}$/);
21 }, "Please specify a valid phone number");