function handleGetFormData() {
const name = document.getElementById(‘name’).value;
const email = document.getElementById(‘email’).value;
const city = document.getElementById(‘city’).value;
const zipCode = document.getElementById(‘zip-code’).value;
const status = document.getElementById(‘status’).checked;
return {
name,
city,
email,
zipCode,
status
};
}
function isNumber(inputString) {
return !isNaN(inputString);
}
function checkboxIsChecked() {
return handleGetFormData().status;
}
function validateFormData(formData) {
if (!formData) return false;
if (!isNumber(formData.zipCode)) return false;
if (!formData.status) return false;
return true;
}
function submit(event) {
event.preventDefault();
const formData = handleGetFormData();
const warningDiv = document.getElementById(‘warning’);
if (!validateFormData(formData)) {
warningDiv.textContent = “Periksa form anda sekali lagi.”;
} else {
warningDiv.textContent = “”;
}
}
const form = document.getElementById(‘mental-health-form’);
form.addEventListener(‘submit’, submit);
Permisi kak, tu kodingan js saya pas ditekan periksa salah terus no 6-10 saya gak tau apa penyebabnya, mohon bantuannya.