/// file: public/assets/js/modules/forms.js

export function initForms() {
  const form = document.querySelector('.contact-form');
  if (!form) return;
  form.addEventListener('submit', (e) => {
    let ok = true;
    form.querySelectorAll('[required]').forEach((field) => {
      if (field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement) {
        if (!field.value.trim()) ok = false;
      }
    });
    if (!ok) {
      e.preventDefault();
    }
  });
}
