Check if the value matches given Javascript regular expression.
Option | Equivalent HTML attribute | Type | Description |
---|---|---|---|
message |
data-bv-regexp-message |
String | The error message |
regexp (*) |
data-bv-regexp-regexp or pattern |
String | The Javascript regular expression |
In the following form, user is asked to enter the full name which alphabetical characters and spaces only.
<form id="profileForm" class="form-horizontal">
<div class="form-group">
<label class="col-lg-3 control-label">Full name</label>
<div class="col-lg-4">
<input type="text" class="form-control" name="fullName" />
</div>
</div>
</form>
<script>
$(document).ready(function() {
$('#profileForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
fullName: {
validators: {
regexp: {
regexp: /^[a-z\s]+$/i,
message: 'The full name can consist of alphabetical characters and spaces only'
}
}
}
}
});
});
</script>
<form id="profileForm" class="form-horizontal">
<div class="form-group">
<label class="col-lg-3 control-label">Full name</label>
<div class="col-lg-4">
<input type="text" class="form-control" name="fullName"
pattern="^[a-z\s]+$"
data-bv-regexp-message="The full name can consist of alphabetical characters and spaces only" />
</div>
</div>
</form>
<script>
$(document).ready(function() {
$('#profileForm').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.