Ver Mensaje Individual
  #5 (permalink)  
Antiguo 09/01/2013, 16:37
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 16 años, 7 meses
Puntos: 1012
Respuesta: caracteres maximos y recuento en textarea

no sabía que el atributo maxlength para textarea era html5 y no es soportado por ie ni opera

edito

dejo otra manera de hacerlo con una función y un evento. en este caso es ayudandonos del objeto event
Cita:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
function fnc(evt, txtarea, max) {
var key = (evt.keyCode) ? evt.keyCode : evt.charCode;
var unidad = (key == 8) ? -1 : 1, cantidad = parseInt(txtarea.length + unidad);
if (cantidad > max || cantidad < 0) {return false;}
document.getElementById('c').innerHTML = cantidad;
}
</script>
</head>
<body>
<form>
<textarea id="t" onkeydown="return contCaracteres(event, this.value, 10);"></textarea>
<span id="c">0</span> de 200
</form>
</body>
</html>
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}

Última edición por IsaBelM; 09/01/2013 a las 17:10