-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
35 lines (31 loc) · 936 Bytes
/
script.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
const handleGetFormData = () => ({
name: document.getElementById('name').value,
email: document.getElementById('email').value,
city: document.getElementById('city').value,
zipCode: document.getElementById('zip-code').value,
status: document.getElementById('status').checked,
});
function isNumber(num) {
if (isNaN(num)) {
return false;
} else {
return true;
}
}
function checkboxIsChecked() {
if (document.getElementById('status').checked) {
return true;
} else {
return false;
}
}
const validateFormData = (obj) =>
obj && isNumber(obj.zipCode) && checkboxIsChecked();
function submit() {
if (validateFormData(handleGetFormData()) == false) {
return (document.getElementById("warning").innerHTML =
"Periksa form anda sekali lagi");
} else {
return (document.getElementById("warning").innerHTML = "");
}
}