PROGRAMACION APLICADA A LA WEB
sábado, 27 de octubre de 2012
Validar cedula
<html>
<head>
<script type="text/javascript">
function validarcedula()
{
var i;
var cedula;
var acumulado;
cedula=document.formacedula.textocedula.value;
var instancia;
acumulado=0;
for (i=1;i<=9;i++)
{
if (i%2!=0)
{
instancia=cedula.substring(i-1,i)*2;
if (instancia>9) instancia-=9;
}
else instancia=cedula.substring(i-1,i);
acumulado+=parseInt(instancia);
}
while (acumulado>0)
acumulado-=10;
if (cedula.substring(9,10)!=(acumulado*-1))
{
alert("Cedula no valida!!");
document.formacedula.textocedula.setfocus();
}
alert("Cedula valida !!");
}
</script>
</head>
<body>
<form name="formacedula">
<input type="text" id="textocedula" onchange="validarcedula()">
</form>
</body>
</html>
Valor mas bajo
<html>
<head>
<b>DaTos</b>
</head>
<body>
<form>
<p> bajo<input type="text" name="baj" onChange = "validar()" > </p>
<p> medio <input type="text" name="med" onChange = "validar()" > </p>
<p> alto<input type="text" name="alt" onChange = "validar()" > </p>
<p> <input type ="button" value="Probar" onClick="validar(baj.value, med.value, alt.value)" > </p>
</form>
</body>
<script type="text/javascript">
function validar(v){
y= v.length
for(i=0; i<y; i++){
z= v.substring(i,i+1);
if((z!="0") && (z!="1" )&&( z!="2") && (z!="3") && (z!="4") && (z!="5") && (z!="6") && (z!="7") && (z!="8") && (z!="9") )
{}
else{
alert("solo valores numericos")}
}
}
function resultado(x,y,z){
if ((x<y) && (x<z)){
if(y<z){
alert("correcto")
else{
alert("error el numero medio es mayor")
}
}
}
else{
alert("Error ")
}
}
</script>
</html>
Numero binario Practica
<html>
<head>
<b>Clase25-09-2012</b>
</head>
<body>
<form>
<input type="text" name="nota1" onChange = "validar(this.value)" >
<input type ="button" value="Validar" onClick="resultado()" >
</form>
</body>
<script type="text/javascript">
function validar(x){
a=0
y= x.length
for(i=0; i<y; i++){
z= x.substring(i,i+1);
if((z=="0") || (z=="1" ) ){
a=a+1
}
}
if (a == y){
alert("si es binario")}
else{
alert("No es binario")
}
}
</script>
</html>
Cuestionario #2
<html>
<head>
<tittle><center><h1>CUESTIONARIO</center></tittle>
<h2>Cristobal colon descubrio America.?</h2> </p>
<input type="radio" value="1" name="musica" id="idex1">Verdadero<BR>
<input type="radio"name="musica"value="2" id="idex2">Falso<BR>
<input type="radio"name="musica"value="3" id="idex3">Ninguna de las anteriores </p>
<h2>De que color es el caballo blanco de Simon Bolivar.?</h2> </p>
<input type="radio" value="4" name="simon" id="idex4" >Blanco<BR>
<input type="radio"name="simon"value="5" id="idex5" >Amarillo <BR>
<input type="radio"name="simon"value="6" id="idex6" >Rosado </p>
<h2>Cuales son los colores de la bandera del Ecuador.?</h2> </p>
<input type="checkbox"name="check[]" id="check7" value="7" >Amarillo</p>
<input type="checkbox"name="check[]" id="check8" value="8">Azul</p>
<input type="checkbox"name="check[]" id="check9" value="9">Rojo</p>
<h2>Cuales son Animales Domesticos...?</h2> </p>
<input type="checkbox"name="check[]" id="check10" value="10">Gallina</p>
<input type="checkbox"name="check[]" id="check11" value="11">Tigre</p>
<input type="checkbox"name="check[]" id="check12" value="12">Perro</p>
<input type ="button" value="enviar" onClick="resultado()" >
<script type="text/javascript">
function resultado(){
pre1=5;
cero=0;
if (document.getElementById('idex1').checked &&
!document.getElementById('idex2').checked&&
!document.getElementById('idex3').checked)
{
primera=pre1;
}
else
primera=cero;
if (document.getElementById('idex4').checked &&
!document.getElementById('idex5').checked&&
!document.getElementById('idex6').checked)
{
segunda=pre1;
} else
segunda=cero;
if (document.getElementById('check7').checked &&
document.getElementById('check8').checked&&
document.getElementById('check9').checked)
{
tercera=pre1;
} else
tercera=cero;
if (document.getElementById('check10').checked &&
!document.getElementById('check11').checked&&
document.getElementById('check12').checked)
{
cuarta=pre1;
} else
cuarta=cero;
suma=primera+segunda+tercera+cuarta;
{
alert ("Su puntaje es "+suma);
}
}
</script>
</html>
Datos practica
<html>
<head>
<b>DaTos</b>
</head>
<body>
<form>
<p> Nombre <input type="text" name="nota1" onChange = "validar(this.value)" >
<p> Telefomo <input type="text" id="nota2" onChange = "validar(this.value)" >
<p> Direccion <input type="text" id="nota3" onChange = "validar(this.value)" >
</form>
</body>
</html>
Etiquetas
<script type= "text/javascript>
function hola mundo()
<p>Usuario
<input type="text" onkeypress="hola mundo" id="nombre" name="nombre">
<input type="text" onchange="hola mundo" id="nombre" name="nombre">
</script>
Suscribirse a:
Entradas (Atom)