From ce7c6ed0491e5b59e4ff7cc4f8a71ec222c2e9ca Mon Sep 17 00:00:00 2001 From: Pavan Shanmukha Madhav Gunda Date: Tue, 1 Oct 2024 23:33:21 +0530 Subject: [PATCH] Password spchar regex added and warning while adding password regarding no special symobols --- Html-files/scriptsignup.js | 28 ++++++++++++++++++++++- Html-files/signup.html | 46 ++++++++++++++++++++++++++++++++++---- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/Html-files/scriptsignup.js b/Html-files/scriptsignup.js index 8a507e93..a26f5fd9 100644 --- a/Html-files/scriptsignup.js +++ b/Html-files/scriptsignup.js @@ -34,7 +34,33 @@ document.getElementById("signup-form").addEventListener("submit", function(event const email = document.getElementById("email").value; const password = document.getElementById("password").value; - if (validateForm(name, email, password)) { + const nameError = document.getElementById("name-error"); + const passwordError = document.getElementById("password-error"); + const emailError = document.getElementById("email-error"); + + // Reset error messages + nameError.textContent = ""; + passwordError.textContent = ""; + emailError.textContent = ""; + + // Regex to prevent <, >, ", or / in the name and password + const spcharexp = /[<>"/]/; + + let valid = true; // A flag to track validation status + + // Name validation + if (spcharexp.test(name)) { + nameError.textContent = "Name cannot contain <, >, \", or /"; + valid = false; + } + + // Password validation + if (spcharexp.test(password)) { + passwordError.textContent = "Password cannot contain <, >, \", or /"; + valid = false; + } + + if (validateForm(name, email, password) && valid) { // Simulate a successful registration (Replace with actual Firebase sign-up logic) console.log("Form submitted with:", { name, email, password }); window.location.href = "../Html-files/signed.html"; diff --git a/Html-files/signup.html b/Html-files/signup.html index f0f80c1a..bcaa38c9 100644 --- a/Html-files/signup.html +++ b/Html-files/signup.html @@ -125,6 +125,38 @@ text-shadow: 0px 0px 2px rgb(90, 90, 90), 0px 0px 5px gray; transform: translateZ(-40px); } +.error-message { + color: red; + font-size: 0.9em; + } + .textfield { + margin-bottom: 15px; + } + /* Tooltip styling */ + .tooltip { + position: relative; + display: inline-block; + } + .tooltip .tooltiptext { + visibility: hidden; + width: 200px; + background-color: #555; + color: #fff; + text-align: center; + border-radius: 5px; + padding: 5px; + position: absolute; + z-index: 1; + bottom: 125%; /* Position above the input field */ + left: 50%; + margin-left: -100px; /* Center the tooltip */ + opacity: 0; + transition: opacity 0.3s; + } + .tooltip:hover .tooltiptext { + visibility: visible; + opacity: 1; + } .area .way:nth-child(1):hover ~ .box{transform: rotateX(-20deg) rotateY(20deg);} .area .way:nth-child(2):hover ~ .box{transform: rotateX(-20deg) rotateY(0deg);} .area .way:nth-child(3):hover ~ .box{transform: rotateX(-20deg) rotateY(-20deg);} @@ -186,15 +218,21 @@

SIGN U
+
+
-
- - -
+ +
+ + + + Special characters such as /[<>"/]/ are not allowed +
+