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

121
Vistas
Label for hidden date input not working on Chrome

I have a date input and I want it to have a placeholder, so I added a label and a display none. I have this code:

    document.querySelector("#date").onchange = (e) => {
      document.querySelector("#datelabel").innerHTML = e.target.value;
    }
    #datelabel {
        padding: 16px;
        border-radius: 15px;
        border: 2px solid rgba(0, 0, 0, 0.8);
        outline: none;
        font-size: 20px;
        transition: .2s;
        width: 200px;
        display: block;
    }
    <input type="date" name="date" id="date" style="display:none;">
    <label class="input" for="date" style="color:var(--text);" id="datelabel">Date</label>

It works fine on Firefox, but not on Chrome. If I remove the display of none of the input, it works, but I don't want the real input to be visible.

I tried to set a height and width to 0, an overflow: hidden, to remove the paddings and margins, but it created a mess in the display of my page, so I want to keep the display of none and find another solution.

Edit: I hid it another way:

position: absolute;
visibility: hidden;

It works now.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this, it works

input {
    padding: 16px;
    border-radius: 15px;
    border: 2px solid rgba(0, 0, 0, 0.8);
    outline: none;
    font-size: 20px;
    transition: .2s;
    width: 200px;
    display: block;
}
::placeholder {
  color:black;
  font-size: 25px;
  
}
   <input type="text" name="date" id="date" id="datelabel" style="display:block;" placeholder="Date">

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