Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/06/2012, 14:18
gusanosxr
 
Fecha de Ingreso: junio-2012
Ubicación: Santiago de Chile
Mensajes: 164
Antigüedad: 11 años, 11 meses
Puntos: 1
Respuesta: Limitar textarea!

Cita:
Iniciado por sjj Ver Mensaje
Probá con esto (este permite 125 caracteres):
Código HTML:
<script language="JavaScript" type="text/javascript">

function cuenta (campo, cuentacampo, limite) {
if (campo.value.length > limite) campo.value = campo.value.substring(0, limite);
else cuentacampo.value = limite - campo.value.length;
}
</script> 
Y el formulario con el textarea:

Código HTML:
<form name="form1">
<textarea name="mensaje" wrap=physical cols="15" rows="5" onKeyDown="cuenta(this.form.mensaje,this.form.remLen,125);" onKeyUp="cuenta(this.form.mensaje,this.form.remLen,125);"></textarea>
<input type="text" name="remLen" size="3" maxlength="3" value="125" readonly>Caracteres restantes:
</form> 





COMPA TODO BIEN, PERO NO ME CUENTA LAS CARACTERES, MI FORM SE LLAMA DATOS_SOLICITUD Y MI TEXTAREA SE LLAMA TXT_OTROS LOS CAMBIE OBVIAMENTE EN EL CÓDIGO QUE ME DISTE, PERO NADA...GRACIAS Y SI ME PUEDES AYUDAR UN POCO MÁS SERÍA BUENO


<textarea name="txt_otros" wrap= physical rows="3" cols="60" onKeyDown = "cuenta(this.datos_solicitud.txt_otros,this.datos_ solicitud.remLen,20);" onKeyUp="cuenta(this.datos_solicitud.txt_otros,thi s.datos_solicitud.remLen,20);"></textarea>
<input type="text" name="remLen" size="3" maxlength="3" value="20" readonly>
</form>