| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- (function($) {
- $.fn.bootstrapValidator.i18n.lessThan = $.extend($.fn.bootstrapValidator.i18n.lessThan || {}, {
- 'default': 'The value must be less than or equal to %s',
- notInclusive: 'The value must be less than %s',
- getMessage: function(options) {
- return (options.inclusive === true || options.inclusive == undefined)
- ? $.fn.bootstrapValidator.helpers.format(this['default'], options.value)
- : $.fn.bootstrapValidator.helpers.format(this.notInclusive, options.value);
- }
- });
- $.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));
|