Sha256: 4d8b6f2e50399b1f8d1788ad6b290a8d1394f59dba0f48d51c48374f72038638

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

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

    $.fn.bootstrapValidator.validators.identical = {
        html5Attributes: {
            message: 'message',
            field: 'field'
        },

        /**
         * Check if input value equals to value of particular one
         *
         * @param {BootstrapValidator} validator The validator plugin instance
         * @param {jQuery} $field Field element
         * @param {Object} options Consists of the following key:
         * - field: The name of field that will be used to compare with current one
         * @returns {Boolean}
         */
        validate: function(validator, $field, options) {
            var value = $field.val();
            if (value === '') {
                return true;
            }

            var compareWith = validator.getFieldElements(options.field);
            if (compareWith === null) {
                return true;
            }

            if (value === compareWith.val()) {
                validator.updateStatus(options.field, validator.STATUS_VALID, 'identical');
                return true;
            } else {
                return false;
            }
        }
    };
}(window.jQuery));

Version data entries

4 entries across 4 versions & 2 rubygems

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