This site contains the document for old version. Please upgrade to the latest version v1.0.0

stringCase validator

Check if a string is a lower or upper case one

Validators

Options

Option HTML attribute Type Description
case data-fv-stringcase-case String Can be lower default or upper
message data-fv-stringcase-message String The error message
When setting options via HTML attributes, remember to enable the validator by setting data-fv-stringcase="true".
The message and other options can be updated on the fly via the updateMessage() and updateOption() methods

Example

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

<form id="stringCaseForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-xs-4 control-label">Credit card holder</label>
        <div class="col-xs-6">
            <input type="text" class="form-control" name="name" />
        </div>
    </div>
</form>

<script>
$(document).ready(function() {
    $('#stringCaseForm').formValidation({
        framework: 'bootstrap',
        icon: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            name: {
                validators: {
                    stringCase: {
                        message: 'The card holder must be in uppercase',
                        'case': 'upper'
                    }
                }
            }
        }
    });
});
</script>
<form id="stringCaseForm" class="form-horizontal"
    data-fv-framework="bootstrap"
    data-fv-icon-valid="glyphicon glyphicon-ok"
    data-fv-icon-invalid="glyphicon glyphicon-remove"
    data-fv-icon-validating="glyphicon glyphicon-refresh">

    <div class="form-group">
        <label class="col-xs-4 control-label">Credit card holder</label>
        <div class="col-xs-6">
            <input type="text" class="form-control" name="name"
                data-fv-stringcase="true"
                data-fv-stringcase-case="upper"
                data-fv-stringcase-message="The card holder must be in uppercase" />
        </div>
    </div>
</form>

<script>
$(document).ready(function() {
    $('#stringCaseForm').formValidation();
});
</script>