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

183
Vistas
How to check if a string contains at least one letter in JavaScript?

I am on validation work. this is my code

if (pwd.match(/[A-Za-z]/)) {
      $("#pwd-complexity-letter").html(good); 
      console.log("pwd complexity  invoked");
}

but this code has checked every string that I am passing through 'pwd'. For example, if I pass numbers or special char code become invoked and satisfying my input has at least one letter. how can I solve this please help. the problem is still on the small letter [a-z] checking. Capital letter only satisfy capital inputs. but the small letter has passed every string.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

For this you can use javascript regexp

var regexp = /^[a-z]+$/i;
if (regexp.test(pwd)) {
  $("#pwd-complexity-letter").html(good); 
  console.log("pwd complexity  invoked");
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use regexp for it:

[a-z] will match any letter from a to z while /i will tell the regex to be case insensitive.

if (isPasswordValid("a1235@")) {
  console.log("Password valid")
} else {
  console.log("Password invalid")
};


function isPasswordValid(psw) {
  let regex = /^[a-z]/i
  return regex.test(psw) // you test if the passed string match the regex, if it does the function will return true else false.
}

You can use a function like isPasswordValid and pass your psw value in it to check if it's valid or not

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