-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.js
43 lines (39 loc) · 1.47 KB
/
register.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function validateForm() {
var form=document.getElementById("registro");
for(i=0; i<form.childNodes.length; i++){
if(form.childNodes[i].tagName!='INPUT' ||typeof form.childNodes[i].value=="undefined")
continue;
else{
var x = form.childNodes[i].value;
if(x == null || x==""){
alert("Porfavor rellene los campos antes de enviar");
return false;
}
}
}
if(document.getElementById("pass").value!=document.getElementById("pass2").value){
alert("Contraseñas diferentes");
return false;
}
return search_inDB()
}
function search_inDB() {
var xhttp = new XMLHttpRequest();
var params = 'uname='+document.getElementById("uname").value+'&email='+document.getElementById("email").value+'&pass='+document.getElementById("pass").value;
xhttp.open("POST", "registrarse.php", true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send(params);
xhttp.onreadystatechange =function(){
if(this.readyState==4 && this.status==200){
if(xhttp.responseText=='Registrado Exitosamente'){
alert("Registrado Exitosamente");
window.open('Login.html','_self');
}
else{
alert(xhttp.responseText);
}
return false;
}
}
return false;
}