Validacion Numero de Telefono


La Siguiente Funcion NosMuestra La Validacion del Numero de Telefono Teniendo como Parametros los Digitos Correspondientes 


<html>
<head>
<title>Validacion de numero de telefono</title>
<script type="text/javascript">
function esnumero(parametro){
var d;
var c
d=parametro.length
for(i=0; i<d; i++)
{
c=parametro.substring(i,i+1);
if((c!="-") && (c!="0") && (c!="1") && (c!="2") && (c!="3") && (c!="4") && (c!="5") && (c!="6") && (c!="7") && (c!="8") && (c!="9"))
return false;
}
return true;
}
function validarnumero(){
var b=document.getElementById("telefono").value;
if(b.length!=11)
{
alert("Telefono invalido");return;
}
if((b.substring(3,4)!="-") || (b.substring(7,8)!="-"))
{
alert("telefono invalido");return;
}
if(esnumero(b)==false)
{
alert("Ingrese numeros por favor");return;
}
alert ("Telefono valido")
}
</script>
</head>
<body bgcolor="F6F3D3">
<form name="prueba">
<input type="text" name="telefono" id="telefono"onChange="validarnumero()" />
<input type="button" name="validar" value="Validar">
</form>
</body>
</html>

0 Response to Validacion Numero de Telefono

Publicar un comentario