Bisa tolong bantu cek?
// Tambahkan kode JavaScript kalian di file ini
function handleGetFormData () {
var name = document.getElementById('name').value;
var city = document.getElementById('city').value;
var email = document.getElementById('email').value;
var zipCode = document.getElementById('zip-code').value;
var status = document.getElementById('status').checked
return {
name,
city,
email,
zipCode,
status
};
}
function isNumber(inputString) {
return !isNaN(inputString);
}
function checkboxIsChecked() {
return document.getElementById('status').checked;
}
function validateFormData(formData) {
if(isNumber(formData.zipCode) && checkboxIsChecked() && formData){
return true;
}
else {
return false;
}
}
function submit(event) {
const formData = handleGetFormData();
const warning = document.getElementById("warning");
if (!validateFormData(formData)) {
warning.textContent = 'Periksa form anda sekali lagi.';
} else {
warning.textContent = '';
}
}
document.getElementById('submit-form').addEventListener('click', (event) => {
event.preventDefault();
submit()
})