master
*anna* 4 years ago
parent bacbf1e437
commit 0da3781af3

@ -23,9 +23,9 @@
<label for="player2"> <img id="player_img_2" src="imgs/dog2.gif" width="100px"></label><br>
</form>
<form action="0_start.html">
<input type="submit" onclick="storeName();isEmpty();" value="start"></form>
<!-- <form action="0_start.html">
<input type="submit" onclick="storeName()" value="start"></form>-->
<button id="gotostart" onclick="storeName()">start</button>
</div>

@ -12,15 +12,21 @@ function updateAvatar () {
var avatar=fd.get("player_avatar")
console.log("avatar", avatar);
localStorage.myavatar=avatar;
}
// store username in local storage + make sure the player added it
// store username in local storage + make sure the player added their preferences, if yes it redirect to the following page
function storeName(){
var inputPlayer = document.querySelector('#player_name').value;
localStorage.playerName=inputPlayer;
if( document.querySelector('#player_name').value === '' ){
alert('empty');
if (document.querySelector('#player_name').value === '') {
alert('Please make sure you declared your preferences');
}
else {
window.location.href = "0_start.html";
}
}

Loading…
Cancel
Save