Sha256: 7a6e77a3c621d67bfb9c14692a35cc62a7bce1663eb8d5782191461bc46a5582

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

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

    $.fn.bootstrapValidator.validators.notEmpty = {
        enableByHtml5: function($field) {
            var required = $field.attr('required') + '';
            return ('required' === required || 'true' === required);
        },

        /**
         * Check if input value is empty or not
         *
         * @param {BootstrapValidator} validator The validator plugin instance
         * @param {jQuery} $field Field element
         * @param {Object} options
         * @returns {Boolean}
         */
        validate: function(validator, $field, options) {
            var type = $field.attr('type');
            if ('radio' === type || 'checkbox' === type) {
                return validator
                            .getFieldElements($field.attr('data-bv-field'))
                            .filter(':checked')
                            .length > 0;
            }

            return $.trim($field.val()) !== '';
        }
    };
}(window.jQuery));

Version data entries

4 entries across 4 versions & 2 rubygems

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