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

136
Views
¿Cómo lo hago donde solo puede tener entre 15 y 80 años al ingresar la fecha de nacimiento?

 window.onload = function() { var date = new Date(); var dd = date.getDate(); var mm = date.getMonth() + 1; var yyyy = date.getFullYear(); //Add a zero if one Digit (eg: 05,09) if (dd < 10) { dd = "0" + dd; } //Add a zero if one Digit (eg: 05,09) if (mm < 10) { mm = "0" + mm; } minYear = yyyy - 80; //Calculate Minimun Age (<80) maxYear = yyyy - 18; //Calculate Maximum Age (>18) var min = minYear + "-" + mm + "-" + dd; var max = maxYear + "-" + mm + "-" + dd; document.getElementById("start").setAttribute("min", min); document.getElementById("start").setAttribute("max", max); };
 <form> <label for="start">Date of birth:</label> <input type="date" id="start" required="required" name="trip-start" value="2021-10-02" /> <input type="submit" /> </form>

¿Qué estoy haciendo exactamente mal aquí? Mi JavaScript no funciona. Solo funciona como JavaScript en línea, pero por alguna razón anula mi otro código JavaScript y aún no funciona, así que creé un archivo JS externo separado para probarlo, pero no funciona.

Nota: No puede ser JavaScript en línea.

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

0

También tienes que configurar el detector de eventos.

 function getEvent(){ var age = getElementById("start").value; if(age<18 || age> 80){ console.log("age should be between 18 and 80") } } <input type"submit" onclick="getEvent()" name="click here">
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!