forked from jaiswaladi246/Boardgame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (48 loc) · 1.74 KB
/
Copy pathscript.js
File metadata and controls
53 lines (48 loc) · 1.74 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
function verify() {
try {
var password = document.forms['form']['password'].value;
var userName = document.forms['form']['userName'].value;
if (password == null || password == "" || userName == null || userName == "") {
document.getElementById("error").innerHTML = "User name and password are required";
return false;
}
var checkboxes = document.getElementsByName("authorities");
var okay = false;
var arr = [];
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
okay = true;
arr.push(checkboxes[i].value);
// break;
}
}
if (arr.length == 0) {
document.getElementById("error").innerHTML = "You must select at least one role";
okay = false;
} else {
okay = true;
}
var okay2 = true;
if (arr.includes("ROLE_MANAGER") && !arr.includes("ROLE_USER")) {
document.getElementById("error").innerHTML = "To add a manager role, you should ALSO check a user role";
okay2 = false;
} else {
okay2 = true;
}
console.log('okay1: ' + okay + " okay2: " + okay2);
return okay && okay2;
} catch (err) {
alert(err);
}
}
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('ROLE_MANAGER').onclick = function () {
var userCheckbox = document.getElementById('ROLE_USER');
var managerCheckbox = document.getElementById('ROLE_MANAGER');
if (!managerCheckbox.checked) {
userCheckbox.checked = false;
} else {
userCheckbox.checked = true;
}
}
});