Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/05/2011, 07:54
miriamgomez
 
Fecha de Ingreso: abril-2008
Mensajes: 348
Antigüedad: 16 años
Puntos: 1
Contar-Limitar caracteres en un input tex

Hola :

Buscando como limitar los caracteres en un input text, di con este codigo:

Código HTML:
Ver original
  1. <html>
  2. <head>
  3.     <title>Untitled</title>
  4.     <script>
  5.     function contar(esto){
  6.     cuantas=esto.length
  7.     if(cuantas>99){document.forms[0].cosa.value=esto.substring(0,99)}
  8.     document.forms[0].total.value=cuantas;
  9.      
  10.     }
  11.      
  12.     </script>
  13. </head>
  14.  
  15. <body>
  16. <form>
  17. <textarea cols="20" rows="5" name="cosa" onkeydown="contar(this.value)"></textarea>
  18. <input type="text" name="total" id="total" size="3" maxlength="3" value=0 readonly>
  19. </form>
  20.  
  21.  
  22. </body>
  23. </html>

Pero me gustaria saber como hacer para que por ejemplo tenga un minimo u un maxino de caracteres.

Un saludo