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

180
Vistas
JavaScript Email Pattern returning true for invalid format

I'm not going to reinvent the wheel. so after surfing google, (not that much expert in regx stuff) i found below function.

function emailPatternCheck(input){      
   var email= /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   return email.test(input); 
 } 

it's supposed to return false for emailPatternCheck('example123@demo.com.com.com') . but getting true.

Could some tell me where should do modification to avoid .com.com.com

Sample input

emailPatternCheck('example123@demo.com') // true, expected
emailPatternCheck('ex_123@demo.com') // true, expected
emailPatternCheck('ex-123@demo.com') // true, expected
emailPatternCheck('#$%#$@demo.com') // false, expected
emailPatternCheck('example@@@asdf.com') // false, expected
emailPatternCheck('example@$%#%.com') // false, expected

emailPatternCheck('example123@demo.com.com.com') should be false not true

Thanks

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