La siguiente página utiliza la función de length para contar el número de caracteres que el usuario ingrese y devolverle el número.
Código:
<html>
<script>
function calcular()
{
var v_texto = document.getElementById("texto").value;
var v_resultado = document.getElementById("resultado").value;
n = v_texto.length;
document.getElementById("resultado").value=n;
}
</script>
<body bgcolor=lightgreen>
<form name="form1" method="post" action="">
<center>
<h2>FUNCIONES TEXTO - CONTAR CARACTERES</h2>
<h3>
TEXTO:
<input type="text" name="texto" id="texto"><p>
RESULTADO:
<input type="text" name="resultado" id="resultado" placeholder="Resultado"><p>
<input type="button" onclick="calcular()" name="r" id="r" value="Procesar"><p>
</h3>
</center>
</form>
</body>
</html>
No hay comentarios:
Publicar un comentario