(function($) { $.fn.bootstrapValidator.validators.lessThan = { html5Attributes: { message: 'message', value: 'value', inclusive: 'inclusive' }, enableByHtml5: function($field) { var max = $field.attr('max'); if (max) { return { value: max }; } return false; }, /** * Return true if the input value is less than or equal to given number * * @param {BootstrapValidator} validator The validator plugin instance * @param {jQuery} $field Field element * @param {Object} options Can consist of the following keys: * - value: The number used to compare to * - inclusive [optional]: Can be true or false. Default is true * - message: The invalid message * @returns {Boolean} */ validate: function(validator, $field, options) { var value = $field.val(); if (value == '') { return true; } value = parseFloat(value); return (options.inclusive === true || options.inclusive==undefined) ? (value <= options.value) : (value < options.value); } }; }(window.jQuery));