\n```\n\n### 2. Show or hide fields conditionally\nDisplay fields based on previous answers.\n\n```html\n\n\n
\n \n
\n\n
\n \n
\n\n\n```\n\n### 3. Use event listeners for interaction\nAttach listeners to inputs so the form updates in real time.\n\n```js\ndocument.querySelector(\"#name\").addEventListener(\"input\", (e) => {\n console.log(\"User typed:\", e.target.value);\n});\n```\n\n### 4. Validate dynamically\nAdd validation rules depending on the user’s selections.\n\n```js\nform.addEventListener(\"submit\", (e) => {\n const age = document.querySelector(\"#age\").value;\n if (age < 18) {\n e.preventDefault();\n alert(\"You must be 18 or older.\");\n }\n});\n```\n\n### 5. Render from a configuration object\nFor more scalable forms, define fields in a JSON-like structure and generate the form from it.\n\n```js\nconst formConfig = [\n { type: \"text\", name: \"firstName\", label: \"First Name\" },\n { type: \"email\", name: \"email\", label: \"Email\" },\n];\n\nformConfig.forEach(field => {\n // create label and input dynamically\n});\n```\n\n## Best practices\n- Use **event delegation** for forms with many dynamic elements.\n- Keep form state in JavaScript if the form is complex.\n- Validate both **client-side and server-side**.\n- Prefer accessibility: include proper `