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

318
Vistas
Validate 2 datetime-local in javascript/jQuery

I have a form where I want to validate 2 datetime-local a start-date and an end-date. What I want is to not let the user select a start date older than 48 hours (browser time) and the end date to not be set in past. This is my code till now:

<form>
  <tr>
     <td>
      <input type="datetime-local" name="start_timestamp" id="start_timestamp" required>
     </td>
                
     <td>
      <input type="datetime-local" name="end_timestamp" id="end_timestamp" required>
     </td>
 </tr>
</form>

And the js so far (PS: I am not very good at js)

var start_date = document.getElementById("start_timestamp").value;
var end_date = document.getElementById("end_timestamp").value;
var now = new Date().toDateString();

    if (end_date < start_date) {
        return 1;
    }
    else {
        return 0;
    }

    if (start_date < now-2) {
        return 1;
    }
    else {
        return 0;
    }
about 4 years ago · Juan Pablo Isaza
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