• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

215
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);
almost 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda