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

171
Views
how can i validate data in dd-mm-yyyy format

I have the following date "13-05-2022"

if (!validateDate(this.formGeral.value.data.singleDate?.formatted)) {
  this.errors.push('Data com formato inválido! Selecione a data de entrega novamente, se o problema persistir, favor entrar em contato com a nossa equipe.');
}

I use this validator, but it only validates in yyyy-mm-dd format

export function validateDate(date: string) {
  const regex = new RegExp('([0-9]{4}[-](0[1-9]|1[0-2])[-]([0-2]{1}[0-9]{1}|3[0-1]{1}))');
  return regex.test(date);
}

How could I validate a date with dd-mm-yyyy format?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

function validateDate(date) {
  const regex = new RegExp('([0-2]{1}[0-9]{1}|3[0-1]{1})[-](0[1-9]|1[0-2])[-]([0-9]{4})');
  return regex.test(date);
}

console.log(validateDate('2020-10-10')) // false
console.log(validateDate('10-10-2020')) // true

about 4 years ago · Juan Pablo Isaza Report
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!