• Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Precios
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

104
Vistas
Regex matching between 6 and 24 letters, numbers, underscores and hyphens

My current regex is /^[A-Za-z0-9_-]\w{5,23}$/ and it matches everything but the hyphen. I tried \- and still no soup. Anybody with a little more experience know how to catch the hyphen?

let errmsg = document.querySelector("#error");
let input_box = document.querySelector("#password");

function checkPassword(value) { 
  var regex =  /^[A-Za-z0-9_-]\w{5,23}$/;
  if (!regex.test(value.target.value))
  {
    console.log(value.target.value);
    errmsg.style.display = 'block';
    input_box.style.borderColor = 'red';
  }
  else
  {
    errmsg.style.display = 'none';
    input_box.style.borderColor = 'black';
  }
}
input_box.addEventListener('input', checkPassword);
9 months 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 empleo Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.