Validators / emailAddress

Validate an email address.

Options

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

You can use type="email" attribute to enable this validator.

Why does empty email address still pass?

This validator passes an empty field since the field might be optional. If the field is required, then use the notEmpty validator.

Example

Email address Result
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
"much.more unusual"@example.com
"[email protected]"@example.com
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
admin@mailserver1
!#$%&'*+-/=?^_`{}|[email protected]
" "@example.org
üñîçøðé@example.com
üñîçøðé@üñîçøðé.com
Abc.example.com
A@b@[email protected]
a"b(c)d,e:f;gi[j\k][email protected]
just"not"[email protected]
this is"not\[email protected]
this\ still\"not\\[email protected]
<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'
        }
    });
});