Validators / identical

Check if the value is the same as one of particular field.

Options

Option HTML attribute Type Description
field* data-bv-identical-field String The name of field that will be used to compare with current one
message data-bv-identical-message String The error message

Example

The following form requires the password and confirmation one to be the same using identical validator.

<form id="registerForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-lg-3 control-label">Password</label>
        <div class="col-lg-5">
            <input type="password" class="form-control" name="password" />
        </div>
    </div>

    <div class="form-group">
        <label class="col-lg-3 control-label">Retype password</label>
        <div class="col-lg-5">
            <input type="password" class="form-control" name="confirmPassword" />
        </div>
    </div>
</form>
$(document).ready(function() {
    $('#registerForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            password: {
                validators: {
                    identical: {
                        field: 'confirmPassword',
                        message: 'The password and its confirm are not the same'
                    }
                }
            },
            confirmPassword: {
                validators: {
                    identical: {
                        field: 'password',
                        message: 'The password and its confirm are not the same'
                    }
                }
            }
        }
    });
});

The following validators might be useful to you: