-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathangelsignup.js
64 lines (58 loc) · 1.71 KB
/
angelsignup.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Angel Signup
Frank Giddens
November 3, 2018
*/
"use strict";
let socket = io.connect();
let fields = ["userName", "password", "email", "phone", "firstName", "lastName", "maidenName", "address", "address2", "city", "state", "zipCode", "references", "reason", "crisisExperience", "volunteerExperience", "criminalHistory", "backgroundCheck", "legalDisclaimer"];
let required = [true, true, true, true, true, true, false, true, false, true, true, true, true, true, false, false, false, true, true];
document.getElementById("sendInfo").addEventListener("click", function(){
let acceptInfo = true;
let info = {};
for(let i = 0; i < fields.length - 2; i++){
if(i < fields.length - 2){
console.log(fields[i]);
if(required[i] && document.getElementById(fields[i]).value == ""){
acceptInfo = false;
//i = fields.length;
}
info[fields[i]] = document.getElementById(fields[i]).value;
}
else{
if(document.getElementById(fields[i]).checked == false){
acceptInfo = false;
//i = fields.length;
}
else{
info[fields[i]] = true;
}
}
}
if(info.userName.length < 8 || info.userName.length > 24){
acceptInfo = false;
alert("Invalid Username: Username must have between 8 and 24 characters");
}
if(info.password.length < 8 || info.password.length > 24){
acceptInfo = false;
alert("Invalid Password: Password must have between 8 and 24 characters");
}
if(info.email.indexOf("@") < 1){
acceptInfo = false;
window.alert("Invalid Email Address");
}
if(!acceptInfo){
alert("Incomplete Form");
}
else{
socket.emit("signupAngel", info);
}
});
socket.on("signupReceived", function(data){
if(data.success){
location = "angelsignupsuccess.html";
}
else{
alert("Username Taken");
}
});