HTML:
Código HTML:
Como ven tengo un input text en el cual cuando hay onkeyup me llame una función con el nombre usuarios, dicha función es esta:Ver original
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> </head> * <body> <form id="form1" name="form1" method="get" action=""> * <input type="text" name="usuario" id="usuario" onkeyup="usuarios(this.value)" /> * <br /> </form> </body> </html>
Javascipt:
Código Javascript:
Ver original
function usuarios(nueno){ * * * * var usuario; * * * * if(nuevo.length==0){ * * * * * * document.getElementById("ErrorUser").innerHTML=""; * * * * * * return; * * * * } * * * * if (window.XMLHttpRequest){ * * * * * * usuario=new XMLHttpRequest(); * * * * }else{ * * * * * * usuario=new ActiveXObject("Microsoft.XMLHTTP"); * * * * } * * * * *usuario.onreadystatechange=function(){ * * * * * * if (usuario.readyState==4 && usuario.status==200){ * * * * * * * * document.getElementById("ErrorUser").innerHTML=usuario.responseText; * * * * * * } * * * * } * * * * usuario.open("GET","usuarios.php?verificarUser="+nuevo,true); * * * * usuario.send(); * * }
Dicha función busca un archivo llamado usuarios.php y envía la variable verificarUser a dicho archivo, en este archivo tengo el siguiente código:
PHP:
Código PHP:
Ver original
* * * * $nuevouser = $_GET['verificarUser']; * * * * if($nuevouser==$fila['usuario']){ * * * * echo "El Usuario ya Existe Use Otro"; * * }else{ * * * * echo "Usuario Disponible"; * * }
Según mi lógica todo esta bien pero yo soy un bruto que está aprendiendo, alguien que me pueda orientar se lo agradecería mucho.