|
|
@@ -2,7 +2,7 @@
|
|
|
* BootstrapValidator (http://bootstrapvalidator.com)
|
|
|
* The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
|
|
|
*
|
|
|
- * @version v0.5.0-dev, built on 2014-06-29 9:46:23 PM
|
|
|
+ * @version v0.5.0-dev, built on 2014-07-01 8:05:04 AM
|
|
|
* @author https://twitter.com/nghuuphuoc
|
|
|
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
|
|
|
* @license MIT
|
|
|
@@ -88,13 +88,9 @@
|
|
|
// Find all fields which have either "name" or "data-bv-field" attribute
|
|
|
.find('[name], [data-bv-field]')
|
|
|
.each(function() {
|
|
|
- var $field = $(this);
|
|
|
- if (that._isExcluded($field)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- var field = $field.attr('name') || $field.attr('data-bv-field'),
|
|
|
- opts = that._parseOptions($field);
|
|
|
+ var $field = $(this),
|
|
|
+ field = $field.attr('name') || $field.attr('data-bv-field'),
|
|
|
+ opts = that._parseOptions($field);
|
|
|
if (opts) {
|
|
|
$field.attr('data-bv-field', field);
|
|
|
options.fields[field] = $.extend({}, opts, options.fields[field]);
|
|
|
@@ -6117,7 +6113,8 @@
|
|
|
$.fn.bootstrapValidator.validators.zipCode = {
|
|
|
html5Attributes: {
|
|
|
message: 'message',
|
|
|
- country: 'country'
|
|
|
+ country: 'country',
|
|
|
+ countryfield: 'countryfield'
|
|
|
},
|
|
|
|
|
|
COUNTRIES: ['CA', 'DK', 'GB', 'IT', 'NL', 'SE', 'SG', 'US'],
|
|
|
@@ -6130,6 +6127,7 @@
|
|
|
* @param {Object} options Consist of key:
|
|
|
* - message: The invalid message
|
|
|
* - country: The ISO 3166 country code
|
|
|
+ * - counryfield: Another field that contains the country code
|
|
|
*
|
|
|
* Currently it supports the following countries:
|
|
|
* - US (United State)
|
|
|
@@ -6144,11 +6142,12 @@
|
|
|
*/
|
|
|
validate: function(validator, $field, options) {
|
|
|
var value = $field.val();
|
|
|
- if (value === '' || !options.country) {
|
|
|
+ if (value === '' || (!options.country && !options.countryfield)) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- var country = (options.country || 'US').toUpperCase();
|
|
|
+ var cField = options.countryfield ? validator.getFieldElements(options.countryfield) : null;
|
|
|
+ var country = (cField ? cField.val() : null || options.country || 'US').toUpperCase();
|
|
|
if ($.inArray(country, this.COUNTRIES) === -1) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -6168,7 +6167,7 @@
|
|
|
case 'SG': return /^([0][1-9]|[1-6][0-9]|[7]([0-3]|[5-9])|[8][0-2])(\d{4})$/i.test(value);
|
|
|
case 'US':
|
|
|
/* falls through */
|
|
|
- default: return /^\d{4,5}([\-]\d{4})?$/.test(value);
|
|
|
+ default: return /^\d{4,5}([\-]?\d{4})?$/.test(value);
|
|
|
}
|
|
|
},
|
|
|
|