Last active
January 1, 2016 21:09
-
-
Save manuel14/8202099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(vista) | |
def comprobar(request): | |
usuario = request.POST["user"] | |
password = request.POST["pass"] | |
user = authenticate(username=usuario, password= password) | |
if user is not None: | |
return HttpResponse(simplejson.dumps(True), context_instance=RequestContext(request)) | |
else: | |
return HttpResponse(simplejson.dumps(False), context_instance=RequestContext(request)) | |
(javascript) | |
$(document).ready(function(){ | |
$("#boton").click(function(event) { | |
usuario = $("#usuario").val() | |
password = $("#password").val() | |
$.post('validar', {user:usuario, pass:password}, function(respuesta){ | |
if (JSON.parse(respuesta)){ | |
alert("Registro exitoso")} | |
else{ | |
alert("Usuario o constraseña no valida") } | |
} ) | |
}); | |
slider() | |
}) | |
(Html) | |
<html> | |
<head> | |
</head> | |
<body> | |
<form id="formulario" method="post"> | |
{% csrf_token %} | |
<label>Usuario</label> | |
<input type="text" id="usuario" > | |
<label>Contraseña</label> | |
<input type="password" id="password"> | |
<input type="submit" value="enviar" id="boton"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment