Validate an email address.
Option | HTML attribute | Type | Description |
---|---|---|---|
message |
data-bv-emailaddress-message |
String | The error message |
You can use type="email"
attribute to enable this validator.
This validator passes an empty field since the field might be optional. If the field is required, then use the notEmpty
validator.
<form id="emailForm" class="form-horizontal">
<div class="form-group">
<label class="col-lg-3 control-label">Email address</label>
<div class="col-lg-7">
<input type="text" class="form-control" name="email" />
</div>
</div>
</form>
$(document).ready(function() {
$('#emailForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
email: {
validators: {
emailAddress: {
message: 'The value is not a valid email address'
}
}
}
}
});
});
<form id="emailForm" class="form-horizontal">
<div class="form-group">
<label class="col-lg-3 control-label">Email address</label>
<div class="col-lg-5">
<input class="form-control" name="email"
type="email"
data-bv-emailaddress-message="The value is not a valid email address" />
</div>
</div>
</form>
$(document).ready(function() {
$('#emailForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
}
});
});