Validators / integer

Edit on Github

Validate an integer number. Accept both positive and negative number.

Option Equivalent HTML attribute Type Description
message data-bv-integer-message String The error message

You can use HTML 5 type="number" attribute to enable this validator.

Example

<form id="integerForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-lg-4 control-label">Type a number</label>
        <div class="col-lg-3">
            <input type="text" class="form-control" name="number" />
        </div>
    </div>
</form>
<script>
$(document).ready(function() {
    $('#integerForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            number: {
                validators: {
                    integer: {
                        message: 'The value is not an integer'
                    }
                }
            }
        }
    });
});
</script>
<form id="integerForm" class="form-horizontal">
    <div class="form-group">
        <label class="col-lg-4 control-label">Type an integer number</label>
        <div class="col-lg-3">
            <input class="form-control" name="number"
                type="number" data-bv-integer-message="The value is not an integer" />
        </div>
    </div>
</form>
<script>
$(document).ready(function() {
    $('#integerForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        }
    });
});
</script>

Comments

If you want to report a bug, please submit the issue on Github. Do NOT post the issue here.

For a general question or feedback, use the form below.