Validate an email address
|Option ||HTML attribute ||Type ||Description |
|String ||The error message |
|String ||Allow multiple email addresses, separated by a comma or semicolon. The default value is |
|String ||Regex for character or characters expected as separator between addresses. By default, it is /[,;]/, i.e. comma or semicolon |
When setting options via HTML attributes, remember to enable the validator by setting data-fv-emailaddress="true".
You don't need to do that when using HTML 5 type="email" attribute.
This validator passes an empty field since the field might be optional. If the field is required, then use the notEmpty
You also can use the remote validator to connect and validate the email address on the server. The Using Mailgun API to validate email address example demonstrates how to do this.
HTML 5 example
The emailAddress validator will be enabled automatically when using HTML 5
Is a@b valid email address?
Yes! It's valid email address. If you want to treat these kind of email addresses as invalid one, you can use the regexp validator to define expression of email address.
The following example uses this approach and borrow the idea from Showing one message example to archive this.