-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Form Example</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="form"> | ||
<form action=""> | ||
|
||
<h2>Sign Up</h2> | ||
<fieldset> | ||
<legend>Email</legend> | ||
<input type="email" id="email"> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend>Password</legend> | ||
<div class="password-container"> | ||
<input type="password" id="password"> | ||
<button type="button" id="togglePassword"> | ||
<span id="eyeIcon">👁</span> | ||
</button> | ||
</div> | ||
</fieldset> | ||
|
||
<button type="submit">Login</button> | ||
</form> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
document.querySelector("form").addEventListener("submit", function (event) { | ||
event.preventDefault(); | ||
|
||
const email = document.getElementById("email").value.trim(); | ||
const password = document.getElementById("password").value.trim(); | ||
|
||
let isValid = true; | ||
|
||
if (!email) { | ||
alert("Email is required."); | ||
isValid = false; | ||
} else if (!/^\S+@\S+\.\S+$/.test(email)) { | ||
alert("Please enter a valid email address."); | ||
isValid = false; | ||
} | ||
|
||
if (!password) { | ||
alert("Password is required."); | ||
isValid = false; | ||
} else if (password.length < 8) { | ||
alert("Password must be at least 8 characters long."); | ||
isValid = false; | ||
} else if (!/[A-Z]/.test(password)) { | ||
alert("Password must contain at least one uppercase letter."); | ||
isValid = false; | ||
} else if (!/[a-z]/.test(password)) { | ||
alert("Password must contain at least one lowercase letter."); | ||
isValid = false; | ||
} else if (!/[0-9]/.test(password)) { | ||
alert("Password must contain at least one number."); | ||
isValid = false; | ||
} | ||
|
||
if (isValid) { | ||
alert("Form submitted successfully!"); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
body{ | ||
font-family: 'Poppins', sans-serif; | ||
background-color: wheat; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.form{ | ||
background: rgb(199, 177, 158); | ||
/* margin: auto; */ | ||
display: flex; | ||
align-items: center; | ||
gap: 20px; | ||
padding: 20px; | ||
border: 2px solid rgb(91, 91, 11); | ||
width: 30%; | ||
} | ||
|