greaterThan.js 820 B

12345678910111213141516171819
  1. (function($) {
  2. $.fn.bootstrapValidator.validators.greaterThan = {
  3. /**
  4. * Return true if the input value is greater than or equals to given number
  5. *
  6. * @param {BootstrapValidator} validator Validate plugin instance
  7. * @param {jQuery} $field Field element
  8. * @param {Object} options Can consist of the following keys:
  9. * - value: The number used to compare to
  10. * - inclusive [optional]: Can be true or false. Default is true
  11. * - message: The invalid message
  12. * @returns {boolean}
  13. */
  14. validate: function(validator, $field, options) {
  15. var value = parseFloat($field.val());
  16. return (options.inclusive === true) ? (value > options.value) : (value >= options.value);
  17. }
  18. }
  19. }(window.jQuery));