// Tambahkan kode JavaScript kalian di file ini
//6. Function handleGetFormData untuk membaca inputan dan kembalikan objek
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
});
//7. function pengecekan isNumber untuk zipcode
function isNumber(zipCode){
if(isNaN(zipCode)){
return false
} else {
return true
}
}
//8. function mengecek inputan checkbox untuk tombol submit
function checkboxIsChecked(status) {
return document.getElementById("status").checked;
}
//9. validasi objek, zipcode dan status
const formData = {
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 validateFormData(formData) {
if(formData!==null && typeof formData.zipCode == "number" && document.getElementById("status").checked ==true){
return true;
} else{
return false;
}
}
//10. submit
function submit(){
const warning= document.getElementById("warning");
const data = handleGetFormData();
if(validateFormData(data)==false) {
return warning.textContent = "Periksa form anda sekali lagi";
} else{
return warning.textContent = "";
}
}
document.getElementById(‘submit-form’).addEventListener(‘click’, (event) => {
event.preventDefault();
submit()
})
salahnya di nomor 10 apa yah?