-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
51 lines (45 loc) · 2.73 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//generate pin
function getPin(){
const pin = Math.round(Math.random() * 10000)
const pinString = pin + ''
if (pinString.length == 4) {
return pin
}else{
return getPin()
}
}
function generatePin(){
const pin = getPin()
document.getElementById('display-pin').value = pin
}
//set keypad value
document.getElementById('key-pad').addEventListener('click',(event) => {
const number = event.target.innerText
const calc = document.getElementById('typed-numbers')
if(isNaN(number)){
if (number === 'C') {
calc.value =' '
}
}
else{
const previoudCalc = calc.value
const newCalc = previoudCalc + number
calc.value = newCalc
}
})
//submit button and checking pin
function verifyPin(){
const pin = document.getElementById('display-pin').value
const typedNumbers = document.getElementById('typed-numbers').value
//fail notify
const failError = document.getElementById('notify-fail')
const successNotify = document.getElementById('notify-success')
if (pin == typedNumbers) {
successNotify.style.display = 'block'
failError.style.display = 'none'
} else {
failError.style.display = 'block'
successNotify.style.display = 'none'
}
typedNumbers.value = ' '
}