// Example: Basic client-side validation or UX improvements document.addEventListener("DOMContentLoaded", function () { const form = document.querySelector("form"); form.addEventListener("submit", async (e) => { e.preventDefault(); const password = document.getElementById("password").value; const cPassword = document.getElementById("cPassword").value; if (password !== cPassword) { alert("Passwords do not match!"); return; } handleSubmit(); }); }); function handleSubmit() { // Example: collect form data manually const form = document.querySelector("form"); const formData = new FormData(form); const payload = { userDetails: {} }; formData.forEach((value, key) => { // handle nested names like userDetails[firstName] if (key.startsWith("userDetails[")) { const innerKey = key.match(/userDetails\[(.*?)\]/)[1]; payload.userDetails[innerKey] = value; } else { payload[key] = value; } }); // You could then send it via fetch: fetch("/api/v1/va/register", { method: "POST", body: JSON.stringify(payload), }) .then((res) => res.json()) .then((data) => { console.log("Server Response:", data); alert("Form submitted successfully!"); }) .catch((err) => console.error("Error:", err)); }