From 10b458d5e97c5afcf50bee2faefb21c8ad63034c Mon Sep 17 00:00:00 2001 From: Tuhin Poddar Date: Fri, 8 Dec 2023 21:47:33 +0530 Subject: [PATCH] Add solutions for Week 2, Day 13 --- Tuhin_Poddar/Week_2/Day_13/q1.css | 8 ++++++++ Tuhin_Poddar/Week_2/Day_13/q1.html | 22 ++++++++++++++++++++++ Tuhin_Poddar/Week_2/Day_13/q1.js | 25 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 Tuhin_Poddar/Week_2/Day_13/q1.css create mode 100644 Tuhin_Poddar/Week_2/Day_13/q1.html create mode 100644 Tuhin_Poddar/Week_2/Day_13/q1.js diff --git a/Tuhin_Poddar/Week_2/Day_13/q1.css b/Tuhin_Poddar/Week_2/Day_13/q1.css new file mode 100644 index 0000000..e7bcd5f --- /dev/null +++ b/Tuhin_Poddar/Week_2/Day_13/q1.css @@ -0,0 +1,8 @@ +input[type="submit"] { + background-color: blue; + color: white; + padding: 8px 16px; + border: none; + border-radius: 4px; + cursor: pointer; +} diff --git a/Tuhin_Poddar/Week_2/Day_13/q1.html b/Tuhin_Poddar/Week_2/Day_13/q1.html new file mode 100644 index 0000000..199b80b --- /dev/null +++ b/Tuhin_Poddar/Week_2/Day_13/q1.html @@ -0,0 +1,22 @@ + + + + + + User Information + + + +

User Information

+
+
+

+ +
+

+ + +
+ + + diff --git a/Tuhin_Poddar/Week_2/Day_13/q1.js b/Tuhin_Poddar/Week_2/Day_13/q1.js new file mode 100644 index 0000000..18be749 --- /dev/null +++ b/Tuhin_Poddar/Week_2/Day_13/q1.js @@ -0,0 +1,25 @@ +document.addEventListener("DOMContentLoaded", function () { + const form = document.getElementById("userForm"); + + form.addEventListener("submit", function (event) { + event.preventDefault(); // Prevents the form from submitting by default + + const nameInput = document.getElementById("name"); + const emailInput = document.getElementById("email"); + const emailFormat = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // Regex for basic email validation + + // Validate name field + if (nameInput.value.trim() === "") { + alert("Please enter your name."); + return; + } + + // Validate email field + if (!emailFormat.test(emailInput.value)) { + alert("Please enter a valid email address."); + return; + } + + alert("Form submitted successfully!"); + }); +});