Problem: email should allow +/- characters in user, – in domain.
dash (-) should be allowed anywhere in an email address or domain.
plus (+) is allowed in the username (many people use this for categorization, especially at gmail)
Solution :
var regex = new RegExp("^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})$","i");
This will validated also emails like: username1+username2@gmail-domain.co.uk
Looking for PHP, Laminas or Mezzio Support?
As part of the Laminas Commercial Vendor Program, Apidemia offers expert technical support and services for:
Leave a Reply