Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
How to validate the Display Name and Email Address together in a string using JavaScript or jQuery?

How to validate a Display Name and Email Address in the following format?

"John Doe" johndoe@example.com

After doing the necessary research, the closest SO question I can relate my requirements to is: Extract email and name with regex

However, I couldn't find something solid, online. I am posting this question here in case someone has already developed a solution that they can share with everyone.

Wishful thinking is that if it can behave like MailAddress Class from System.Net.Mail namespace. https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.mailaddress

function ValidateEmailAndDisplayName(emailAddressWithDisplayName) {
    // A solid logic that addresses following test cases.
}

Quouted Display Name: ","

emailAddressWithDisplayName = "John Doe" <johndoe@example.com> //=> True

Display Name without double qoutes:

emailAddressWithDisplayName = John Doe <johndoe@example.com> //=> True

Comma in Quouted Display Name: ","

emailAddressWithDisplayName = "Doe, John" <johndoe@example.com> //=> True

Comma in Display Name without double qoutes: ,

emailAddressWithDisplayName = Doe, John <johndoe@example.com> //=> True

Backslash before adding double qoute: \

emailAddressWithDisplayName = "John \"Middle Name\" Doe" <johndoe@example.com> //=> True

Missing backslash before adding double qoute: \

ValidateEmailAndDisplayName('"John "Middle Name" Doe" <johndoe@example.com>'); //=> False

Missing closing angular bracket: >

emailAddressWithDisplayName = "John Doe" <johndoe@example.com //=> Flase

TIA

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda