-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
100 lines (87 loc) · 3.79 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en" class="h-full" data-theme="light">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SignUp Page</title>
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp,container-queries"></script>
</head>
<body class="h-full flex items-center justify-center bg-gray-100 dark:bg-gray-900">
<div class="absolute top-4 right-4">
<button id="theme-toggle" class="bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-200 px-4 py-2 rounded">
Toggle Theme
</button>
</div>
<div class="w-full max-w-md bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h2 class="text-4xl font-bold text-gray-800 dark:text-gray-100 mb-6">
Sign Up
</h2>
<form id="loginForm">
<div class="mb-4">
<label class="block text-gray-700 dark:text-gray-300 mb-2" for="email">Email</label>
<input
class="w-full px-4 py-2 text-gray-700 dark:text-gray-200 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:border-blue-500 dark:focus:border-blue-400"
type="email" id="email" placeholder="Email" required />
<p id="emailError" class="text-red-500 text-sm mt-1 hidden">
Please enter a valid email.
</p>
</div>
<div class="mb-6">
<label class="block text-gray-700 dark:text-gray-300 mb-2" for="password">Password</label>
<input
class="w-full px-4 py-2 text-gray-700 dark:text-gray-200 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:border-blue-500 dark:focus:border-blue-400"
type="password" id="password" placeholder="Password" required />
<p id="passwordError" class="text-red-500 text-sm mt-1 hidden">
Password must be at least 6 characters.
</p>
</div>
<button type="submit"
class="w-full bg-red-500 dark:bg-red-600 text-white py-2 rounded hover:bg-red-300 hover:bg-red-500 dark:hover:bg-blue-700 focus:outline-none focus:bg-red-600 dark:focus:bg-blue-700">
Submit
</button>
</form>
</div>
<script>
const themeToggleBtn = document.getElementById("theme-toggle");
const rootElement = document.documentElement;
const passwordInput = document.getElementById("password");
// Definir a senha como "admin123" ao carregar a página
passwordInput.value = "admin123";
themeToggleBtn.addEventListener("click", () => {
if (rootElement.classList.contains("dark")) {
rootElement.classList.remove("dark");
rootElement.setAttribute("data-theme", "light");
} else {
rootElement.classList.add("dark");
rootElement.setAttribute("data-theme", "dark");
}
});
const loginForm = document.getElementById("loginForm");
const emailInput = document.getElementById("email");
const emailError = document.getElementById("emailError");
const passwordError = document.getElementById("passwordError");
loginForm.addEventListener("submit", (e) => {
let valid = true;
// Reset error messages
emailError.classList.add("hidden");
passwordError.classList.add("hidden");
// Email validation
const emailValue = emailInput.value.trim();
if (!emailValue || !/^\S+@\S+\.\S+$/.test(emailValue)) {
emailError.classList.remove("hidden");
valid = false;
}
// Password validation
const passwordValue = passwordInput.value.trim();
if (!passwordValue || passwordValue.length < 6) {
passwordError.classList.remove("hidden");
valid = false;
}
// If not valid, prevent form submission
if (!valid) {
e.preventDefault();
}
});
</script>
</body>
</html>