Código HTML:
function GuardaFormulario()
{
var TELEFONO = document.forms['form1'].elements['TELEFONO'];
if (TELEFONO.value.length == 0)
{
alert("Insertar el Teléfono");
TELEFONO.focus();
return 0;
}
else
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "valida1.php?TELEFONO=" + TELEFONO.value, false);
xmlhttp.send();
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var xml = xmlhttp.responseXML;
dato=xml.getElementsByTagName("datos");
if(dato[0].firstChild.nodeValue=="1")
{
num_user=xml.getElementsByTagName("numusuario");
if (confirm("¡Usuario existente!¿Desea hacer un nuevo registro?"))
{
document.forms['form1'].action = location.protocol+'//'+location.hostname+"/"+"menu3.php?id="+num_user[0].firstChild.nodeValue;
}
else
{
document.forms['form1'].action = location.protocol+'//'+location.hostname+"/"+"menu4.php";
}
}
if(dato[0].firstChild.nodeValue=="0")
{
alert("¡El Cliente se ha dado de alta!");
document.forms['form1'].submit();////Aquí mando el formulario si el teléfono no existe.
}
}
}
}
Hola mira a ver así...
salu2 ;)