diff options
Diffstat (limited to 'Lab05/script.js')
-rw-r--r-- | Lab05/script.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lab05/script.js b/Lab05/script.js new file mode 100644 index 0000000..c8a542c --- /dev/null +++ b/Lab05/script.js @@ -0,0 +1,32 @@ +document.addEventListener("DOMContentLoaded", function () { + const form = document.getElementById("registrationForm"); + + form.addEventListener("submit", function (event) { + event.preventDefault(); // Prevent the default form submission behavior + + const fname = document.getElementById("fname").value; + const lname = document.getElementById("lname").value; + const gender = document.getElementById("gender").value; + const phone = document.getElementById("phone").value; + const email = document.getElementById("email").value; + const address = document.getElementById("address").value; + const department = document.querySelector('input[name="department"]:checked'); + + const verificationText = ` + First Name: ${fname}\n + Last Name: ${lname}\n + Gender: ${gender}\n + Phone Number: ${phone}\n + Email Address: ${email}\n + Home Address: ${address}\n + Department: ${department ? department.value : "Not specified"}\n + `; + + const isVerified = window.confirm("Please verify the entered information:\n\n" + verificationText + "\n\nDo you want to proceed?"); + + if (isVerified) { + alert("Form successfully submitted!"); + form.reset(); // Clear the form fields + } + }); +}); |