![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
06/02/2008, 07:35
|
| | Fecha de Ingreso: diciembre-2006 Ubicación: San Lorenzo/Central/Paraguay
Mensajes: 29
Antigüedad: 18 años, 2 meses Puntos: 0 | |
Re: Cómo reproducir el contenido de un campo INPUT en otro YA LO LOGRÉ...
a partir del script de http://www.desarrolloweb.com/articulos/no-sobrepasar-caracteres-permitidos-textarea.html.
<!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=iso-8859-1" />
<title>Que un Textarea no sobrepase longitud en caracteres</title>
<script>
contenido_textarea = ""
num_caracteres_permitidos = 10
function valida_longitud()
{
num_caracteres = document.forms[0].texto.value.length
document.forms[0].texto2.value = document.forms[0].texto.value
if (num_caracteres <= num_caracteres_permitidos)
{
contenido_textarea = document.forms[0].texto.value
}
else
{
document.forms[0].texto.value = contenido_textarea
}
if (num_caracteres >= num_caracteres_permitidos)
{
document.forms[0].caracteres.style.color="#ff0000";
document.forms[0].texto.style.background="#33CC00";
}
else
{
document.forms[0].caracteres.style.color="#000000";
document.forms[0].texto.style.color="#000000";
}
cuenta()
}
function cuenta()
{
document.forms[0].caracteres.value=document.forms[0].texto.value.length
}
</script>
</head>
<body>
<form action="#" method="post">
<table>
<tr>
<td>Texto:</td>
<td><textarea cols="40"
rows="5"
name="texto"
onKeyDown="valida_longitud()"
onKeyUp="valida_longitud()"
></textarea></td>
</tr>
<tr>
<td>Texto:</td>
<td><textarea cols="40"
rows="5"
name="texto2"
onKeyDown="valida_longitud()"
onKeyUp="valida_longitud()"
></textarea></td>
</tr>
<tr>
<td>Caracteres:</td>
<td><input type="text"
name=caracteres
size=4></td>
</tr>
</table>
</form>
</body>
</html> |