Ver Mensaje Individual
  #14 (permalink)  
Antiguo 17/10/2012, 14:47
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Respuesta: Mensaje de alert para cuando el regisrtro existe en la base de datos

Maycol, he quitado la variable respuesta y ya no me hace nada:

Código Javascript:
Ver original
  1. //función responsable de crear el objeto para comunicación asíncrona
  2.  
  3. function nuevoAjax() {
  4.  
  5.  
  6.    var xmlhttp=false;
  7.  
  8.    try   {
  9.  
  10.       // Creacion del objeto AJAX para navegadores no IE
  11.  
  12.    
  13.  
  14.       xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  15.  
  16.    }
  17.  
  18.    catch(e)   {
  19.  
  20.      try  {
  21.  
  22.  
  23.       // Creacion del objet AJAX para IE
  24.  
  25.       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  26.  
  27.      }
  28.  
  29.      catch(E) {
  30.  
  31.        if (!xmlhttp && typeof XMLHttpRequest!='undefined')
  32.  
  33.         xmlhttp=new XMLHttpRequest();
  34.  
  35.      }
  36.  
  37.  
  38.  
  39.    }
  40.  
  41.    return xmlhttp;
  42.  
  43.   }
  44.  
  45.  
  46.  
  47.  function TelefonoExiste(telefono) {
  48.  
  49.       var ajax=nuevoAjax();
  50.  
  51.       ajax.open("GET", "valida1.php?telefono="+telefono, true);
  52.  
  53.       ajax.onreadystatechange=function() {
  54.  
  55.        if ((ajax.readyState==4) && (ajax.status==200)){
  56.        
  57.      TelefonoExiste = ajax.responseText
  58.  
  59.      
  60.       }
  61.  
  62.       ajax.send(null);
  63.  
  64.   }
  65.  
  66.  
  67.  
  68.  
  69.  
  70. function GuardaFormulario() {
  71.  
  72.  
  73.  
  74.     if (document.form1.telefono.value.length==0){
  75.  
  76.       alert("Insertar el Teléfono")
  77.  
  78.       document.form1.telefono.focus()
  79.  
  80.       return 0;
  81.  
  82.      }
  83.  
  84.    else if (TelefonoExiste(document.form1.telefono.value).length==0) {
  85.  
  86.      
  87.  
  88.       document.form1.telefono.focus()
  89.  
  90.       return 0;
  91.  
  92.     }
  93.  
  94.     //el formulario se envia
  95.  
  96.     else
  97.    
  98.        alert("El formulario se envio con exito!")
  99.        document.form1.submit();
  100. }

Gracias.