Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda