-
Notifications
You must be signed in to change notification settings - Fork 0
/
cool.js
28 lines (24 loc) · 987 Bytes
/
cool.js
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
document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector("form");
const usernameInput = form.querySelector("input[type='text']");
const passwordInput = form.querySelector("input[type='password']");
const button = form.querySelector(".btn");
form.addEventListener("submit", function (event) {
event.preventDefault(); // Mencegah pengiriman form default
const username = usernameInput.value.trim();
const password = passwordInput.value.trim();
// Validasi sederhana
if (!username || !password) {
alert("Username dan Password harus diisi!");
return;
}
// Simulasi login
if (username === "Ridwan" && password === "Anita") {
alert("Login berhasil!");
// Tambahkan logika setelah login berhasil, misalnya redirect
window.location.href = "afterLogin.html"; // Contoh redirect
} else {
alert("Username atau Password salah!");
}
});
});