-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (45 loc) · 1.27 KB
/
index.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
function getPin(){
const pin = Math.round(Math.random() * 10000);
const pinString = pin + '';
if(pinString.length == 4){
return pin
}
else{
return getPin();
}
}
function genaretPin(){
const pin = getPin();
console.log(pin);
document.getElementById('display-pin').value = pin;
}
document.getElementById('key-pad').addEventListener('click', function(event){
const number = event.target.innerText;
const clacInput = document.getElementById('typed-number');
if(isNaN(number)){
if(number == 'C'){
clacInput.value = '';
}
}
else {
const preNumber = clacInput.value;
const newCalc = preNumber + number
clacInput.value = newCalc;
}
})
function pinVerify(){
const pin = document.getElementById('display-pin').value;
const typedNumber = document.getElementById('typed-number').value;
const passed = document.getElementById('if-passed');
const faield = document.getElementById('if-failed');
if(typedNumber == pin){
// console.log('matched');
passed.style.display = 'block';
faield.style.display = 'none'
}
else{
// console.log('opps! dont matched');
faield.style.display = 'block'
passed.style.display = 'none'
}
}