-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (28 loc) · 885 Bytes
/
app.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
29
30
31
32
33
34
//SELECTING ELEMENTS FROM THE DOM
const form = document.querySelector('.input-form');
const nameInput = document.getElementById('name-input');
const startLink = document.querySelector('.start-link')
const startBtn = document.querySelector('.start-btn');
const err = document.querySelector('.error');
//WHEN BUTTON CLICK
startBtn.addEventListener('click', (e)=>{
e.preventDefault();
//Get input value
const userName = nameInput.value;
//if input value is > 0
if(userName.length > 0){
//save to local storage
localStorage.setItem('name', userName);
window.location.href ='./rules/rules.html';
}else{
errMsg();
}
});
//-------------------FUNCTIONS----------------------
//error function
const errMsg = ()=>{
err.style.visibility = 'visible';
setTimeout(()=>{
err.style.visibility = 'hidden';
},1500);
}