(function($) { $.fn.bootstrapValidator.validators.stringLength = { /** * Check if the length of element value is less or more than given number * * @param {BootstrapValidator} validator The validator plugin instance * @param {jQuery} $field Field element * @param {Object} options Consists of following keys: * - min * - max * At least one of two keys is required * @returns {Boolean} */ validate: function(validator, $field, options) { var value = $field.val(); if (value == '') { return true; } var length = $.trim(value).length; if ((options.min && length < options.min) || (options.max && length > options.max)) { return false; } return true; } }; }(window.jQuery));