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

184
Views
set an age limit in a form in react js?

The user cannot be less than 0 years old, and more than 100 years old

//format birthday date req.validated.birthdate = moment(req.validated.birthdate, "DD/MM/YYYY").format("YYYY-MM-DD");

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

0

You can use moment().diff

const ageInYears = moment().diff(moment('15/11/1993', "DD/MM/YYYY"), 'years');

if (ageInYears > 100) {
  alert('More than 100 years old')
} else if (ageInYears < 0) {
  alert('Less than 0 years old')
} else {
  alert('Age is fine')
}

Edit: Better code

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!