digits.js 595 B

1234567891011121314151617181920
  1. (function($) {
  2. $.fn.bootstrapValidator.validators.digits = {
  3. /**
  4. * Return true if the input value contains digits only
  5. *
  6. * @param {BootstrapValidator} validator Validate plugin instance
  7. * @param {jQuery} $field Field element
  8. * @param {Object} options
  9. * @returns {Boolean}
  10. */
  11. validate: function(validator, $field, options) {
  12. var value = $field.val();
  13. if (value == '') {
  14. return true;
  15. }
  16. return /^\d+$/.test(value);
  17. }
  18. }
  19. }(window.jQuery));