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

155
Views
React reactstrap date form age 18 or older

I am working on a project that has a form. I am using Reacttsrap for it. One of the fields is a date for the user. I need to use a logic that will allow users with age 18 or older. Also, disable future dates. There isn't much explanation about it in the reactstrap documentation. Also, I have seen many examples online, but I haven't seen one with these requirements and make it work. Currently, I have this code of the form:

<FormGroup>
    <Input 
        id='user-age' 
        name='date' 
        type='date'
        aria-label='Date of birth'
        value={this.state.date}
        // onChange={(event) => this.handleInputChange(event)} 
    />
    <Label for='user-age'>*Date of birth (DD/MM/YY)</Label>
</FormGroup>

The commented code is just an idea of a handler to make it work. Any help would be much appreciated it.

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

0

I just found an answer from here that it helped me solve the issue.

  function getAge(dateString: string | number | Date) {
    var today = new Date();
    var birthDate = new Date(dateString);
    var age = today.getFullYear() - birthDate.getFullYear();
    var m = today.getMonth() - birthDate.getMonth();
    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
        age--;
    }
    return age;
}
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!