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

260
Vistas
Can I get some assistance a regex issue?

I use javascript regex replacements at various places but I have come across something I can't quite get. I have an input box that will always be 10 characters. The first 2 characters will always be a capital letter and the other 8 will always be a number.

Using jQuery's keyup & replace functions (I do this with other regex replacements) I need invalid characters replaced with "" as they are typing. For instance, say the desired input is AB12345678 and while typing the 1st or 2nd character they either type a small letter, number, or other character, it is removed. Same with positions 3-10, if anything other than a number is typed, it gets removed.

As I said I have other spots where I do this but not for specific positions within the input, such as $(this).val($(this).val().replace(/\D/g, "")) only allows the entering of numbers in a box or $(this).val($(this).val().replace(/[^a-zA-Z0-9]+/g, "")) will only only allow upper/lower case letters and numbers.

Ideally I suppose with the first 2 characters if they type a lowercase letter it would get converted to uppercase but for now, will just remove it.

I am probably overlooking something simple for making sure the first 2 characters are entered with only capital letters and the last 8 are only numbers but....

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda