between.js 902 B

12345678910111213141516171819202122
  1. (function($) {
  2. $.fn.bootstrapValidator.validators.between = {
  3. /**
  4. * Return true if the input value is between (strictly or not) two given numbers
  5. *
  6. * @param {BootstrapValidator} validator The validator plugin instance
  7. * @param {jQuery} $field Field element
  8. * @param {Object} options Can consist of the following keys:
  9. * - min
  10. * - max
  11. * - inclusive [optional]: Can be true or false. Default is true
  12. * - message: The invalid message
  13. * @returns {boolean}
  14. */
  15. validate: function(validator, $field, options) {
  16. var value = parseFloat($field.val());
  17. return (options.inclusive === true)
  18. ? (value > options.min && value < options.max)
  19. : (value >= options.min && value <= options.max);
  20. }
  21. };
  22. }(window.jQuery));