|
@@ -22,16 +22,15 @@
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var country = (options.country || 'US').toUpperCase();
|
|
|
|
|
- switch (country) {
|
|
|
|
|
|
|
+ options.country = options.country || 'US';
|
|
|
|
|
+ switch (options.country.toUpperCase()) {
|
|
|
case 'US':
|
|
case 'US':
|
|
|
|
|
+ // Make sure US phone numbers have 10 digits
|
|
|
|
|
+ value = value.replace(/\(|\)|\s+/g, '');
|
|
|
|
|
+ return (/^(?:1\-?)?(\d{3})[\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value) && value.length == 10;
|
|
|
default:
|
|
default:
|
|
|
- // Make sure US phone numbers have 10 digits
|
|
|
|
|
- // May start with 1, +1, or 1-; should discard
|
|
|
|
|
- // Area code may be delimited with (), & sections may be delimited with . or -
|
|
|
|
|
- // Test: http://regexr.com/38mqi
|
|
|
|
|
- value = value.replace(/\(|\)|\s+/g, '');
|
|
|
|
|
- return (/^(?:(1\-?)|(\+1 ?))?\(?(\d{3})[\)\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value) && (value.length == 10);
|
|
|
|
|
|
|
+ value = value.replace(/\D/g,'');
|
|
|
|
|
+ return (/^(?:1\-?)?(\d{3})[\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|