-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
83 lines (76 loc) · 2.51 KB
/
script.js
File metadata and controls
83 lines (76 loc) · 2.51 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function checkValidity() {
let inputs = document.getElementsByClassName("required");
let btn = document.querySelector('button[type="submit"]');
let isValid = true;
for (let i = 0; i < inputs.length; i++) {
let changedInput = inputs[i];
if (changedInput.value.trim() === "" || changedInput.value === null) {
isValid = false;
break;
}
}
return isValid;
}
const email = document.querySelector("#email");
const icon1 = document.querySelector(".icon1");
const icon2 = document.querySelector(".icon2");
const error = document.querySelector(".error-text");
let regExp = /^[^ ]+@["slu"]+\.["edu"]/;
function check() {
if (email.value.match(regExp)) {
email.style.background = "#eafaf1";
icon1.style.display = "none";
icon2.style.display = "block";
error.style.display = "none";
} else {
email.style.background = "#fceae9";
icon1.style.display = "block";
icon2.style.display = "none";
error.style.display = "block";
}
if (email.value === "") {
email.style.borderColor = "lightgrey";
email.style.background = "#f1f1f1";
icon1.style.display = "none";
icon2.style.display = "none";
error.style.display = "none";
}
}
function myFunction(e) {
e.preventDefault();
var valid = checkValidity();
if (!valid) {
alert("Form is invalid");
return;
}
var fname = document.getElementById("fname").value;
var fpaper = document.getElementById("fpaper").value;
var lpaper = document.getElementById("lpaper").value;
var dateId = document.getElementById("dateId").value;
var currentdate = new Date();
var datetime =
currentdate.getFullYear() +
"." +
(currentdate.getMonth() + 1) +
"." +
currentdate.getDate();
var table = document.getElementById("myTable");
var newRow =
'<tr style="height: 82px;">' +
'<td class="u-border-1 u-border-grey-50 u-custom-color-1 u-table-cell u-table-cell-17">' +
dateId +
"</td>" +
'<td class="u-border-1 u-border-grey-50 u-custom-color-1 u-table-cell u-table-cell-18">' +
fname +
"</td>" +
'<td class="u-border-1 u-border-grey-50 u-custom-color-1 u-table-cell u-table-cell-19">' +
fpaper +
"</td>" +
'<td class="u-border-1 u-border-grey-50 u-custom-color-1 u-table-cell u-table-cell-20">' +
' <a class="u-active-none u-border-none u-btn u-button-link u-button-style u-hover-none u-none u-text-palette-1-base u-btn-5" href="' +
lpaper +
'" target="_blank">Paper</a>' +
" </td>" +
"</tr>";
table.tBodies[0].insertAdjacentHTML("afterbegin", newRow);
}