Sha256: 5084b51747dcebea024aa9f1a86d4c653fa6b45e146b1f797c2f928db4c89fa8

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

(function($) {
    $.fn.bootstrapValidator.i18n.integer = $.extend($.fn.bootstrapValidator.i18n.integer || {}, {
        'default': 'Please enter a valid number'
    });

    $.fn.bootstrapValidator.validators.integer = {
        enableByHtml5: function($field) {
            return ('number' === $field.attr('type')) && ($field.attr('step') === undefined || $field.attr('step') % 1 === 0);
        },

        /**
         * Return true if the input value is an integer
         *
         * @param {BootstrapValidator} validator The validator plugin instance
         * @param {jQuery} $field Field element
         * @param {Object} options Can consist of the following key:
         * - message: The invalid message
         * @returns {Boolean}
         */
        validate: function(validator, $field, options) {
            var value = $field.val();
            if (value === '') {
                return true;
            }
            return /^(?:-?(?:0|[1-9][0-9]*))$/.test(value);
        }
    };
}(window.jQuery));

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
bootstrap_validator_rails-0.1.0 vendor/assets/javascripts/validator/integer.js
bootstrap_validator_rails-0.0.6 vendor/assets/javascripts/validator/integer.js
bootstrap_validator_rails-0.0.5 vendor/assets/javascripts/validator/integer.js
bootstrap_validator-rails-0.0.1 vendor/javascripts/validator/integer.js