Validacion De Numeros Binarios


<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>

0 Response to Validacion De Numeros Binarios

Publicar un comentario