Validate an integer number. Accept both positive and negative number.
Option | 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.
<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>
$(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'
}
}
}
}
});
});
<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" step="1" data-bv-integer-message="The value is not an integer" />
</div>
</div>
</form>
$(document).ready(function() {
$('#integerForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
}
});
});
The following validators might be useful to you: