Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!