-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (38 loc) · 1.37 KB
/
main.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
35
36
37
38
39
40
41
42
const nameInput = document.querySelector('#username')
const passwordInput = document.querySelector('#password')
const numberInput = document.querySelector('#number')
const list = document.querySelector('.users')
const error = document.querySelector('.Error')
const idInput = document.querySelector('#id')
const btn = document.querySelector("#button")
const btn_2 = document.querySelector('#button_2')
btn.addEventListener('click' ,(e) =>
{
if(nameInput.value === '' || passwordInput.value === '' || numberInput.value === '' || idInput.value === '' )
{
alert('Please Enter All Fields')
}
else{
const li = document.createElement('li')
li.appendChild(document.createTextNode('Username: ' + nameInput.value + ' -- Password: ' + passwordInput.value + ' -- Mobile: ' + numberInput.value))
list.appendChild(li)
localStorage.setItem(list)
idInput.value = ''
nameInput.value = ''
passwordInput.value = ''
numberInput.value = ''
}
})
btn_2.addEventListener('click' , (e) =>{
if(nameInput.value === '' || passwordInput.value === '' || numberInput.value === '' || idInput.value === '' )
{
alert('Please Enter All Fields')
}
else{
list.children[idInput.value-1].remove()
idInput.value = ''
nameInput.value = ''
passwordInput.value = ''
numberInput.value = ''
}
})