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

185
Vistas
How to reject extra characters entered by the user?

In my HTML, I have an array of inputs. The user should be allowed to enter only one character in each. Here is its HTML:

<input class = "green" type="text" maxlength="1" />

The CSS for this is as follows:

input {
    font: 1.5em "Times New Roman", Times, serif; 
    width:0.9em; height: 0.9em;
    text-align:center; }
.green { 
    color: green; }

If the user enters a character and then tries to enter another, nothing should happen. However, in my design the user can enter any number of characters, even though the earlier characters are pushed to the left and only the last character is visible. When the focus leaves the input field, all extra characters disappear and only the first input character remain. How can I make sure that when the user tries to enter additional characters, they are ignored and nothing happens?

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

0

Is it what you need?

function go(v){
    if (v.value.length==0){
    return true;
  }
    return false;
}
<input class = "green" type="text" maxlength="1" onkeydown="return go(this)"/>

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