|
@@ -2,7 +2,7 @@
|
|
|
* BootstrapValidator (http://bootstrapvalidator.com)
|
|
* BootstrapValidator (http://bootstrapvalidator.com)
|
|
|
* The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
|
|
* The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
|
|
|
*
|
|
*
|
|
|
- * @version v0.5.0-dev, built on 2014-07-06 8:37:51 AM
|
|
|
|
|
|
|
+ * @version v0.5.0-dev, built on 2014-07-06 9:00:01 AM
|
|
|
* @author https://twitter.com/nghuuphuoc
|
|
* @author https://twitter.com/nghuuphuoc
|
|
|
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
|
|
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
|
|
|
* @license MIT
|
|
* @license MIT
|
|
@@ -2870,7 +2870,7 @@
|
|
|
* - Name of field which its value defines the country code
|
|
* - Name of field which its value defines the country code
|
|
|
* - Name of callback function that returns the country code
|
|
* - Name of callback function that returns the country code
|
|
|
* - A callback function that returns the country code
|
|
* - A callback function that returns the country code
|
|
|
- * @returns {Boolean|Object}
|
|
|
|
|
|
|
+ * @returns {Object}
|
|
|
*/
|
|
*/
|
|
|
validate: function(validator, $field, options) {
|
|
validate: function(validator, $field, options) {
|
|
|
var value = $field.val();
|
|
var value = $field.val();
|
|
@@ -4721,20 +4721,7 @@
|
|
|
'default': 'Please enter a value with valid length',
|
|
'default': 'Please enter a value with valid length',
|
|
|
less: 'Please enter less than %s characters',
|
|
less: 'Please enter less than %s characters',
|
|
|
more: 'Please enter more than %s characters',
|
|
more: 'Please enter more than %s characters',
|
|
|
- between: 'Please enter value between %s and %s characters long',
|
|
|
|
|
-
|
|
|
|
|
- getMessage: function(options) {
|
|
|
|
|
- switch (true) {
|
|
|
|
|
- case (!!options.min && !!options.max):
|
|
|
|
|
- return $.fn.bootstrapValidator.helpers.format(this.between, [options.min, options.max]);
|
|
|
|
|
- case (!!options.min):
|
|
|
|
|
- return $.fn.bootstrapValidator.helpers.format(this.more, options.min);
|
|
|
|
|
- case (!!options.max):
|
|
|
|
|
- return $.fn.bootstrapValidator.helpers.format(this.less, options.max);
|
|
|
|
|
- default:
|
|
|
|
|
- return this['default'];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ between: 'Please enter value between %s and %s characters long'
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
$.fn.bootstrapValidator.validators.stringLength = {
|
|
$.fn.bootstrapValidator.validators.stringLength = {
|
|
@@ -4764,8 +4751,14 @@
|
|
|
* - min
|
|
* - min
|
|
|
* - max
|
|
* - max
|
|
|
* At least one of two keys is required
|
|
* At least one of two keys is required
|
|
|
|
|
+ * The min, max keys define the number which the field value compares to. min, max can be
|
|
|
|
|
+ * - A number
|
|
|
|
|
+ * - Name of field which its value defines the number
|
|
|
|
|
+ * - Name of callback function that returns the number
|
|
|
|
|
+ * - A callback function that returns the number
|
|
|
|
|
+ *
|
|
|
* - message: The invalid message
|
|
* - message: The invalid message
|
|
|
- * @returns {Boolean}
|
|
|
|
|
|
|
+ * @returns {Object}
|
|
|
*/
|
|
*/
|
|
|
validate: function(validator, $field, options) {
|
|
validate: function(validator, $field, options) {
|
|
|
var value = $field.val();
|
|
var value = $field.val();
|
|
@@ -4773,12 +4766,34 @@
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var length = value.length;
|
|
|
|
|
- if ((options.min && length < options.min) || (options.max && length > options.max)) {
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ var min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption(options.min, $field),
|
|
|
|
|
+ max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption(options.max, $field),
|
|
|
|
|
+ length = value.length,
|
|
|
|
|
+ isValid = true,
|
|
|
|
|
+ message = options.message || $.fn.bootstrapValidator.i18n.stringLength['default'];
|
|
|
|
|
+
|
|
|
|
|
+ if ((min && length < parseInt(min, 10)) || (max && length > parseInt(max, 10))) {
|
|
|
|
|
+ isValid = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ switch (true) {
|
|
|
|
|
+ case (!!min && !!max):
|
|
|
|
|
+ message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.stringLength.between, [parseInt(min, 10), parseInt(max, 10)]);
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case (!!min):
|
|
|
|
|
+ message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.stringLength.more, parseInt(min, 10));
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case (!!max):
|
|
|
|
|
+ message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.stringLength.less, parseInt(max, 10));
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return { valid: isValid, message: message };
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
}(window.jQuery));
|
|
}(window.jQuery));
|