Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda