From 3de90ac9d97937cd01c0f419e9bef214c71f36ff Mon Sep 17 00:00:00 2001 From: Avansh2006 Date: Thu, 3 Oct 2024 00:20:48 +0530 Subject: [PATCH 1/2] Issue#71 --- assets/css/style.css | 82 ++++++++++++++++++++++++++++++++++++++++++++ assets/js/script.js | 67 ++++++++++++++++++++++++++++++++++++ index.html | 27 +++++++++++++++ 3 files changed, 176 insertions(+) diff --git a/assets/css/style.css b/assets/css/style.css index 380dfd7..e3aba53 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2051,4 +2051,86 @@ textarea.input-field { left: 0; } +} +#blog-section { + width: 50%; + margin: 50px auto; + background-color: white; + padding: 20px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + border-radius: 8px; +} + +h2, h3 { + text-align: center; + color: white; + +} + +.form-group { + margin-bottom: 15px; +} + +label { + display: block; + margin-bottom: 5px; + color: #555; +} + +input, textarea { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; + font-size: 1rem; +} + +button { + display: block; + width: 100%; + padding: 10px; + background-color: #007bff; + color: white; + border: none; + border-radius: 4px; + font-size: 1rem; + cursor: pointer; +} + +button:hover { + background-color: #0056b3; +} + +.error-message { + color: red; + font-size: 0.875rem; +} + +.success-message { + color: green; + text-align: center; + font-size: 1rem; + display: none; +} + +#blogList { + margin-top: 20px; +} + +.blog-entry { + background: #444444; + padding: 15px; + border-radius: 6px; + margin-bottom: 10px; + color: white; + display: grid; + padding-left: 100px; +} + +.blog-entry h4, .blog-entry p { + margin: 0 0 10px; +} +.blogs{ + color: white; + background: #444444; } \ No newline at end of file diff --git a/assets/js/script.js b/assets/js/script.js index 6403e32..77431d9 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -1,3 +1,70 @@ +document.getElementById("blogForm").addEventListener("submit", function(event) { + event.preventDefault(); + + const name = document.getElementById("name").value; + const email = document.getElementById("email").value; + const description = document.getElementById("description").value; + + const isValid = validateForm(name, email, description); + + if (isValid) { + addBlogEntry(name, email, description); + + document.getElementById("successMessage").textContent = "Blog submitted successfully!"; + document.getElementById("successMessage").style.display = "block"; + + document.getElementById("blogForm").reset(); + + setTimeout(() => { + document.getElementById("successMessage").style.display = "none"; + }, 2700); + } else { + alert("Error: Something is wrong!!"); + } +}); + +function validateForm(name, email, description) { + let isCorrect = true; + + if (name.trim() === "") { + document.getElementById("nameError").textContent = "Name is required"; + isCorrect = false; + } + + if (!validateEmail(email)) { + document.getElementById("emailError").textContent = "Please enter a valid email"; + isCorrect = false; + } + + if (description.trim() === "") { + document.getElementById("descriptionError").textContent = "Description is required"; + isCorrect = false; + } + + return isCorrect; +} +// adding the entries and appending it in the div... +function addBlogEntry(name, email, description) { + const blogList = document.getElementById("blogList"); + + const blogEntry = document.createElement("div"); + blogEntry.classList.add("blog-entry"); + + + blogEntry.innerHTML = ` +

Name:${name}
Email:(${email})

+

Description: ${description}

+ `; + + + blogList.appendChild(blogEntry); +} + +function validateEmail(email) { + const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return re.test(email); +} + /** * PRELOAD diff --git a/index.html b/index.html index e97ba51..e469f68 100644 --- a/index.html +++ b/index.html @@ -1178,6 +1178,33 @@

+
+

Submit Your Blog

+
+
+ + + +
+
+ + + +
+
+ + + +
+ +

+
+
+
+

Submitted Blogs

+
+
+ From 31dedd53a863651851924f6a39603d4f59ac2397 Mon Sep 17 00:00:00 2001 From: Avansh2006 Date: Thu, 3 Oct 2024 00:44:22 +0530 Subject: [PATCH 2/2] Issue#72 --- assets/css/style.css | 7 ++++--- index.html | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index e3aba53..51ac308 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2055,7 +2055,7 @@ textarea.input-field { #blog-section { width: 50%; margin: 50px auto; - background-color: white; + background-color: #161718; padding: 20px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); border-radius: 8px; @@ -2083,6 +2083,7 @@ input, textarea { border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; + color: white; } button { @@ -2118,7 +2119,7 @@ button:hover { } .blog-entry { - background: #444444; + background: #0e0d0c; padding: 15px; border-radius: 6px; margin-bottom: 10px; @@ -2132,5 +2133,5 @@ button:hover { } .blogs{ color: white; - background: #444444; + background: #0e0d0c; } \ No newline at end of file diff --git a/index.html b/index.html index e469f68..fcec300 100644 --- a/index.html +++ b/index.html @@ -1182,18 +1182,18 @@

Submit Your Blog

- - + +
- - + +
- - + +
@@ -1201,7 +1201,7 @@

Submit Your Blog

-

Submitted Blogs

+

Submitted Blogs