|
|
@@ -984,6 +984,35 @@
|
|
|
};
|
|
|
}(window.jQuery));
|
|
|
;(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 Consist of key:
|
|
|
+ * - country: The ISO 3166 country code
|
|
|
+ *
|
|
|
+ * Currently it only supports United State (US) country
|
|
|
+ * @returns {Boolean}
|
|
|
+ */
|
|
|
+ validate: function(validator, $field, options) {
|
|
|
+ var value = $field.val();
|
|
|
+ if (value == '') {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ options.country = options.country || 'US';
|
|
|
+ switch (options.country.toUpperCase()) {
|
|
|
+ case 'US':
|
|
|
+ default:
|
|
|
+ value = value.replace(/\(|\)|\s+/g, '');
|
|
|
+ return (/^(?:1\-?)?(\d{3})[\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}(window.jQuery));
|
|
|
+;(function($) {
|
|
|
$.fn.bootstrapValidator.validators.regexp = {
|
|
|
/**
|
|
|
* Check if the element value matches given regular expression
|
|
|
@@ -1193,11 +1222,13 @@
|
|
|
*
|
|
|
* @returns {Boolean}
|
|
|
*/
|
|
|
- validate: function(validateInstance, $field, options) {
|
|
|
+ validate: function(validator, $field, options) {
|
|
|
var value = $field.val();
|
|
|
if (value == '' || !options.country) {
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ options.country = options.country || 'US';
|
|
|
switch (options.country.toUpperCase()) {
|
|
|
case 'DK':
|
|
|
return /^(DK(-|\s)?)?\d{4}$/i.test(value);
|