I am trying to make a Sign Up and Log In html. If user inputs data on SignUp.html, it will save as localStorage and if the data inputted on LogIn.html is not equal to the data inputteed in SignUp.html, it will not confirm. But somehow there is something wrong with the function. Can someone please help me? I am still new to js
Here is SignUp.html
<!DOCTYPE html>
<html>
<head>
<script src = "JS.js"></script>
</head>
<body>
<form>
<input id="usernameS"></input>
<button onclick="confirmInput()" type="button">SignUp</button>
</form>
</body>
</html>
and LogIn.html
<!DOCTYPE html>
<html>
<head>
<script src = "JS.js"></script>
</head>
<body>
<form>
<input id="usernameL"></input>
<button onclick="LogInput()" type="button">LogIn</button>
</form>
</body>
</html>
Here is the js
var x = "document.getElementById('usernameS')";
localStorage.setItem("usernameS", x);
var y = "document.getElementById('usernameL')";
localStorage.setItem("usernameL", y);
function confirmInput() {
alert("Welcome " + usernameS.value + ". You are now registered.");
window.location.replace('LogIn.html'); }
function LogInput(x,y) {
if (x==y)
{unsernameS = document.forms[0].usernameL.value;
alert("Welcome " + usernameL.value + "! You just logged in.");}
else if (x!=y)
alert("Username not recognized");}