FUNCINES TEXTO JS - CONTAR VOCALES EN TEXTO
<html>
<script>
function vocales()
{
var v_texto= document.getElementById("texto").value;
n=v_texto.length; // total caracteres
//alert (n);
var v_total=0;
for(i=0;i<n;i++)
{
c=v_texto.charAt(i);
c=c.toLowerCase();
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
{
v_total++;
}
}
//alert (v_total);
total.value=v_total;
}
</script>
<body>
<form name="form1" method="post" action="">
<center>
<h1> funciones tipo TEXTO- TOTAL VOCALES</h1>
<h2>
nombre:
<input type="text" name="texto" id="texto"> <p>
total vocales:
<input type="text" name="total" id="total"> <p>
<input type="button" onclick="vocales ()" name="r"
id="r" value="procesar"> <p>
</h2>
</center>
</form>
</body>
</html>
**************************************
Ejercicio Valida nombre:
Ingresar un nombre y validar que sea correcto, no lleve números ni caracteres especiales

Comentarios
Publicar un comentario