About the FAQs category

(Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

  • Why should people use this category? What is it for?

  • How exactly is this different than the other categories we already have?

  • What should topics in this category generally contain?

  • Do we need this category? Can we merge with another category, or subcategory?

function submit() {

const data = handleGetFormData();

// Mendapatkan elemen dengan id ‘warning’

const warningDiv = document.getElementById(‘warning’);

// Jika isValid adalah false, tampilkan pesan peringatan

if (validateFormData(data) == false) {

return (warningDiv.textContent = 'Periksa form anda sekali lagi');

} else {

return warningDiv.remove();

}

}

MOHON BANTUANNYA KAK, INI KODE NO 10 MASIH EROR

tolong kak 2 hari nggak bisa nih "// Tambahkan kode JavaScript kalian di file ini
// Function to handle form submission
function handleGetFormData() {
return {
name: document.getElementById(‘name’).value,
city: document.getElementById(‘city’).value,
email: document.getElementById(‘email’).value,
zipCode: document.getElementById(‘zip-code’).value,
status: document.getElementById(‘status’).checked
};
}

// Function to check if a string consists only of numbers
function isNumber(str) {
return /^\d+$/.test(str);
}

// Function to check if checkbox is checked
function checkboxIsChecked() {
return document.getElementById(‘status’).checked;
}

// Function to validate form data
function validateFormData(formData) {
// Check if formData object is not null or undefined
if (!formData) {
return false;
}

// Check if all required fields are filled
if (
    formData.name &&
    formData.city &&
    formData.email &&
    formData.zipCode &&
    isNumber(formData.zipCode) &&
    formData.status
) {
    return true;
} else {
    return false;
}

}

form.addEventListener(‘click’, (event) => {
event.preventDefault();
submit()
})

function submit() {
const data = handleGetFormData();

// Mendapatkan elemen dengan id ‘warning’

const warningDiv = document.getElementById(‘warning’);

// Jika isValid adalah false, tampilkan pesan peringatan

if (validateFormData(data) == false) {
return (warningDiv.textContent = ‘Periksa form anda sekali lagi.’);
} else {
return warningDiv.remove();
}
}

// Event listener to call submit function on form submit
document.getElementById(‘form’).addEventListener(‘submit’, submit);
"