From 4c454dd3ac526314f7ad7509fb597c0d9836ccb2 Mon Sep 17 00:00:00 2001 From: Teena Pranathi <150207921+23WH1A0508@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:52:06 +0530 Subject: [PATCH] Added form enhancements: validation and feedback messages. --- contactus.html | 220 +++++++++++++++++-------------------------------- 1 file changed, 75 insertions(+), 145 deletions(-) diff --git a/contactus.html b/contactus.html index 123d023..b774096 100644 --- a/contactus.html +++ b/contactus.html @@ -5,8 +5,6 @@ - - Contact Us Page @@ -23,163 +21,95 @@ z-index: 1000; /* Ensure the trail is above everything */ pointer-events: none; /* Prevent the circles from interfering with mouse events */ } - - + /* Style for error messages */ + .error-message { + color: red; + font-size: 12px; + display: none; /* Initially hide error messages */ + } + - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - -
-
- -
-
+ +
- -
-
-

Contact Us

-

- At Car Rental Service we are here to assist you with all your car rental needs. Whether you have questions about our services, need help with a reservation, or want to provide feedback, our team is ready to help. Reach out to us via phone, email, or by filling out the contact form below. We look forward to hearing from you and ensuring your car rental experience is smooth and enjoyable. - -Feel free to customize it further to better fit your specific needs! -

-
-
- -
-
- -
-
-
- -
- -
-

Address

-


-
-
- -
-
- -
- -
-

Phone

-

-
-
- -
-
- -
- -
-

Email

-

-
-
-
- -
-
-

Send Message

-
- - Full Name -
- -
- - Email -
- -
- - Type your Message... -
- -
- +
+
+

Contact Us

+

+ At Car Rental Service we are here to assist you with all your car rental needs... +

+
- -
- -
-
-
-
- - + + // Clear previous error messages + nameError.style.display = "none"; + emailError.style.display = "none"; + // Validate Full Name + const fullname = document.getElementById('fullname').value; + if (!fullname) { + nameError.style.display = "block"; // Show error message + valid = false; // Set valid to false + } + // Validate Email + const email = document.getElementById('email').value; + const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // Simple email regex + if (!emailPattern.test(email)) { + emailError.style.display = "block"; // Show error message + valid = false; // Set valid to false + } + + // Prevent form submission if invalid + if (!valid) { + event.preventDefault(); // Stop form submission + } + }); + +