-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidations.js
More file actions
57 lines (49 loc) · 1.57 KB
/
validations.js
File metadata and controls
57 lines (49 loc) · 1.57 KB
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
var games = {
div1:["Calla", "Shape-up", "Kings & Quads", "Hex-A-Gone", "Star Track"],
div2:["Fiar", "Sum Dominoes & Dice", "Quatro Sinko", "Par 55", "Ramrod"],
div3:["Fab-A-Diffy", "Stars & Bars", "Contig 60", "Queens & Guards", "Juggle"],
div4:["Fraction Pinball", "Pent Em' In", "Prime Gold", "Remainder Islands", "Frac Fact"]
};
$("#form").submit(function(event){
var studentNames = $("#studentInputs").val().split(",");
var monitorNames = $("#monitorInputs").val().split(",");
var division = $("#dropdown").val();
var getGames = games[division];
for (var i = 0; i < studentNames.length; i++) {
if (studentNames[i] == "") {
studentNames = studentNames.filter(e => e !== "");
}
}
for (var i = 0; i < monitorNames.length; i++) {
if (monitorNames[i] == "") {
monitorNames = monitorNames.filter(e => e !== "");
}
}
cookie1 = studentNames;
cookie2 = monitorNames;
cookie3 = getGames;
console.log(document.cookie);
console.log(studentNames);
console.log(monitorNames);
//validations
if (studentNames.length === 0){
alert("Please input at least 1 student.");
return false;
}
if (monitorNames.length === 0){
alert("Please input at least 1 monitor.");
return false;
}
for (var i = 0; i < studentNames.length; i++) {
if (studentNames[i] != "" && studentNames[i].length < 4) {
alert("Every student's name should include a first and last name.");
return false;
};
};
for (var i = 0; i < monitorNames.length; i++) {
if (monitorNames[i] != "" && monitorNames[i].length < 4) {
alert("Every monitor's name should include a first and last name.");
return false;
};
};
});