Registration Form
function validateForm() {
var login = document.forms["registrationForm"]["login"].value;
var password = document.forms["registrationForm"]["password"].value;
var confirmPassword = document.forms["registrationForm"]["confirmPassword"].value;
var errorMessage = document.getElementById("errorMessage");
if (login == "" || password == "" || confirmPassword == "") {
errorMessage.innerHTML = "Please fill out all fields.";
return false;
}
if (password != confirmPassword) {
errorMessage.innerHTML = "Passwords do not match.";
return false;
}
localStorage.setItem("login", login);
localStorage.setItem("password", password);
return true;
}
function checkLogin() {
var storedLogin = localStorage.getItem("login");
var storedPassword = localStorage.getItem("password");
var login = prompt("Please enter your login:");
var password = prompt("Please enter your password:");
if (login != storedLogin || password != storedPassword) {
alert("Invalid login or password.");
} else {
alert("Welcome back!");
}
}
Login:
Password:
Confirm Password: