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

145
Vistas
Email validation coding in node.is

This is the email validation coding.

I only know to do example 5, the email length must over 5 strings, otherwise, it will become error and remind people to re-write the email.

I don’t know how to write the example 2-4 based on the email requirements. Kindly please give me some advices. Thank you so much!

function validateEmail(email) {
    console.log(email)
  // email requirements as below:
  // email length >= 5 character
  // @ cannot be the first character
  // @ must before .
  // . cannot be the last character
  // example 
  // 1. a@a.com < return true
  // 2. @a.com < return false, throw TypeError: invalid email address
  // 3. a.b@com < return false, throw TypeError: invalid email address
  // 4. a@a.com. < return false, throw TypeError: invalid email address
  // 5. a@a.c < return false, throw TypeError: e-mail address too short
  // 6. a@.com < return ture
  // example 5, email length >= 5 character
  if(email.length<5) {
    throw new TypeError(`e-mail address too short`)
  }
  // example 4,  . cannot be the last character
  
  }
// example 1,6
    return true

    function newFunction() {
        return "'"
    }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can follow this REGAX for validate email. Please check

const emailToValidate = 'a@a.com';
const emailRegexp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
console.log(emailRegexp.test(emailToValidate));

Thanks

about 4 years ago · Juan Pablo Isaza Denunciar
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