Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/05/2011, 10:40
skin_head77
 
Fecha de Ingreso: febrero-2010
Ubicación: Santiago de chile
Mensajes: 14
Antigüedad: 14 años, 2 meses
Puntos: 1
Información Validar usuario con jquery

Estimados hoy buscando por la Internet no encontré nada relacionado sobre como validar si un usuario se encuentra ya en nuestra BD solo hay ejemplos en php así que pongo como yo lo realice.

HTML
Código:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr> 
<td height="18" colspan="4"> </td>
</tr>
<tr> 
<td height="7" colspan="4"></td>
</tr>						               	
<tr > 
<td width="5">&nbsp;</td>
<td width="146" valign="middle" align="left" ><p><strong style='color:#F00'>Rut : </strong></p> </td>
<td  align="left" width="281"><input   name="txt_rut" class="required"   size="20" value="" type="text" id="txt_rut" maxlength="11"/><div id="DVcomprobar"></div></td>
</tr>
<tr> 
<td height="7" colspan="4"></td>
</tr>
<tr > 
<td width="5">&nbsp;</td>
<td width="146" valign="middle" align="left" ><p><strong style='color:#F00'>Nombre : </strong></p> </td>
<td  align="left" width="281"><input  name="txt_Nombre" class="required"   size="30" value="" type="text" id="txt_Nombre" maxlength="49"/></td>
</tr>
<tr > 
<td width="5">&nbsp;</td>
<td width="146" valign="middle" align="left" ><p><strong style='color:#F00'>Contraseña  : </strong></p></td>
<td align="left" width="281"> <input name="txt_constraseña"  size="25" type="password" id="txt_constraseña" value=""  maxlength="9"/></td>
</tr>
<tr> 

<td height="7" colspan="4"></td>
</tr>
</table>
jquery
Código:
$("#txt_rut").change(function(){
               //si estas trabajando con php recorda cambiar .asp por .php
		$.post("comprobar.asp",{ rut:$(this).val() },function(data){$("#DVcomprobar").html(data);})
		});
ASP COMPROBAR.ASP
Código:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252" %>
<!--#include virtual="xxx.ASP"-->
<%
set conexion=server.createobject("ADODB.Connection") 
conexion.open = strconexion 
set rs=server.createobject("ADODB.Recordset") 
'recibimos 
rutb= Request("rut")
SQL = ""
'ejecutamos la consulta
SQL= "Select *  from tabla_de_usuarios where  campo_a_buscar = '"&rutb&"'"
rs.Open sql,conexion
if not rs.eof and not rs.bof then
	Response.Write("<strong style='color:#F00'>El Usuario Ya esta Ingresado</strong>")
end if 
'cerramos la conexion
rs.Close
Set rs = Nothing
conexion.Close
Set conexion = Nothing
sql = ""
%>
espero les ayude y este es mi primer post con un aporte.....

si hay algo mal me avisan...

Saludos.