|
|
@@ -0,0 +1,21 @@
|
|
|
+(function($) {
|
|
|
+ $.fn.bootstrapValidator.validators.phone = {
|
|
|
+ /**
|
|
|
+ * Return true if the input value contains a valid US phone number only
|
|
|
+ *
|
|
|
+ * @param {BootstrapValidator} validator Validate plugin instance
|
|
|
+ * @param {jQuery} $field Field element
|
|
|
+ * @param {Object} options
|
|
|
+ * @returns {Boolean}
|
|
|
+ */
|
|
|
+ validate: function(validator, $field, options) {
|
|
|
+ var value = $field.val();
|
|
|
+ if (value == '') {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ value = value.replace(/\(|\)|\s+/g, '');
|
|
|
+ return (/^(?:1\-?)?(\d{3})[\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}(window.jQuery));
|