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

158
Vistas
Input[type = 'text'] accept alphabets only instead of alphabets and whitespaces

I want to make my input text field accept alphabets only and space(at least one white space), not only alphabets, i use this expression but only alphabets works but if I put spaces between the text, doesnt work.

const isAlphabet = (input) => {
    const re = /^[a-zA-Z]+$/;
    return re.test(input);
  }
``
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

let change /^[a-zA-Z]+$/ for /^[a-z A-Z]+$/. i saw that someone used \s instead of , so i'm still sending my answer, since expression proposed by me is shorter, better performing (due to handling only space) plus u will gain additional knowledge, how to handle spaces in different way.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use \s (including space, tab, form feed, line feed, and other Unicode spaces)

const isAlphabet = (input) => {
    const re = /^[a-zA-Z\s]+$/;
    return re.test(input);
}
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