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

104
Vistas
Validate RegEx while typing

I have an input field and date schema that I need to validate (dd.mm.yy). I can not use a regular pattern for input, because it should not be allowed users to type letters, they need to type 22 and if the third one is not a dot, the type should be prevented.

The front is written in vue.js so I have

<input v-on:change="changeFunction" :sr-only="true" placeholder="dd.mm.yy"></input>

and then I tried to use functions like this

validate (e) {
      let number = new RegExp('(0[1-9]|[12][0-9]|3[01])[. /.](0[1-9]|1[012])[. /.]')
      let validate = number.test(e)
      if (validate) { return true }
}

and then to validate

changeFunction ({name, value}) {
      
      if (this.validate(value)) {
        do something
      } else {
        do something else
      }
    }

I get true and false once the type is complete, but I can type anything inside the input, not just numbers and dots. So is there any way that I can check RegExp while I am typing number by number and to prevent type if RegExp is not matched

Thanks

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