Validators / stringCase

Check if a string is a lower or upper case one.

Options

Option HTML attribute Type Description
case data-bv-stringcase-case String Can be lower default or upper
message data-bv-stringcase-message String The error message

Example

The following form asks user to enter a credit card holder in uppercase:

<form id="cardHolderForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-lg-4 control-label">Credit card holder</label>
        <div class="col-lg-4">
            <input type="text" class="form-control" name="name" />
        </div>
    </div>
</form>
$(document).ready(function() {
    $('#cardHolderForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            name: {
                validators: {
                    // Since case is a Javascript keyword,
                    // you should place it between quotes (like 'case' or "case")
                    // to make it work in all browsers
                    stringCase: {
                        message: 'The card holder must be in uppercase',
                        'case': 'upper'
                    }
                }
            }
        }
    });
});