Sha256: f485d3c167bacdee9ec92f568824e7351d3ccc2a1955475217f4ed9751eabce6

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

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

    $.fn.bootstrapValidator.validators.numeric = {
        html5Attributes: {
            message: 'message',
            separator: 'separator'
        },

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

        /**
         * Validate decimal number
         *
         * @param {BootstrapValidator} validator The validator plugin instance
         * @param {jQuery} $field Field element
         * @param {Object} options Consist of key:
         * - message: The invalid message
         * - separator: The decimal separator. Can be "." (default), ","
         * @returns {Boolean}
         */
        validate: function(validator, $field, options) {
            var value = $field.val();
            if (value === '') {
                return true;
            }
            var separator = options.separator || '.';
            if (separator !== '.') {
                value = value.replace(separator, '.');
            }

            return !isNaN(parseFloat(value)) && isFinite(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/numeric.js
bootstrap_validator_rails-0.0.6 vendor/assets/javascripts/validator/numeric.js
bootstrap_validator_rails-0.0.5 vendor/assets/javascripts/validator/numeric.js
bootstrap_validator-rails-0.0.1 vendor/javascripts/validator/numeric.js