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

176
Vistas
How to allow only 2 digit numbers in html text input separated by colon?

How to allow only 2 digit numbers in html text input separated by colon?

Desired output 33:33

I tried this

<form name="form1"> 
 <input type="text"  name="pincode" maxlength="4"  id="pin" pattern="\d{4}" required/>
 <input type="Submit"/> 
</form>

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Your regex is wrong. try this:

<form name="form1"> 
 <input type="text"  name="pincode" maxlength="5" id="pin" pattern="\d{2}:\d{2}" required/>
 <input type="Submit"/> 
</form>

about 4 years ago · Santiago Trujillo Denunciar

0

You can use regexp ^\d{2}:\d{2}$ which matches only strings of the form dd:dd, d representing a single digit.

input[name="pincode"]:invalid {
  background-color: red;
}

input[name="pincode"]:valid {
  background-color: green;
}
<form name="form1"> 
 <input type="text"  name="pincode" minlength="5" maxlength="5"  id="pin" pattern="^\d{2}:\d{2}$" required>
 <input type="Submit"> 
</form>

about 4 years ago · Santiago Trujillo 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