Ver Mensaje Individual
  #15 (permalink)  
Antiguo 17/10/2012, 15:11
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 15 años, 10 meses
Puntos: 220
Respuesta: Mensaje de alert para cuando el regisrtro existe en la base de datos

satjaen revisa bien tu código esta todo MAL como menciona maycolalvarez te falta punto y comas te falta cerrar llaves ademas no puedes tener de esa manera estructurado tu codigo esta HORRIBLE, DIFICIL QUE ALGUIEN LO ENTIENDA y te AYUDE.

Varias veces te he ayudado y sigues haciendo lo mismo, esta es la ultima vez que ordeno tu código así debe estar para que este mas entendible

Código Javascript:
Ver original
  1. function nuevoAjax() {
  2.     var xmlhttp=false;
  3.     try {
  4.         xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  5.     }
  6.         catch(e){
  7.         try{
  8.             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  9.         }catch(E) {
  10.             if (!xmlhttp && typeof XMLHttpRequest!='undefined')
  11.                 xmlhttp=new XMLHttpRequest();
  12.         }
  13.     }
  14.     return xmlhttp;
  15. }
  16.  
  17. function TelefonoExiste(telefono) {
  18.     var ajax=nuevoAjax();
  19.     ajax.open("GET", "valida1.php?telefono="+telefono, true);
  20.     ajax.onreadystatechange=function() {
  21.         if ((ajax.readyState==4) && (ajax.status==200)){
  22.             TelefonoExiste = ajax.responseText;
  23.         }
  24.     }
  25.     ajax.send(null);
  26. }
  27.  
  28. function GuardaFormulario() {
  29.     if (document.form1.telefono.value.length==0){
  30.         alert("Insertar el Teléfono");
  31.         document.form1.telefono.focus();
  32.         return 0;
  33.        }else if (TelefonoExiste(document.form1.telefono.value).length==0) {
  34.         document.form1.telefono.focus();
  35.         return 0;
  36.       }
  37.       else{
  38.         alert("El formulario se envio con exito!");
  39.         document.form1.submit();
  40.     }
  41. }

Primero usa por favor colecciones tal como te pongo a continuacion lee por internet por favor como puedes hacerlo document.forms["form1"].elements["myelement"]

Segundo else if (TelefonoExiste(document.form1.telefono.value).len gth==0) como vas a hacer esto para validar el ajax esta completamente mal

Tercero porque asignas el resultado del ajax al mismo nombre de la funcion esto esta tambien mal TelefonoExiste = ajax.responseText;

Por favor corrige todo esto

Saludos
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones