-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
74 lines (58 loc) · 2.66 KB
/
script.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function login(){
window.location.href = 'login.html';
}
function index(){
window.location.href = 'index.html';
}
// LogIn Validitation section
function validateLogin(){
let email = document.getElementById('email').value;
let pass = document.getElementById('password').value;
let validEmail = "[email protected]";
let validPassword = "123456#";
if(email == validEmail && pass == validPassword){
window.location.href = 'wallet.html';
}
else{
alert('Invalid email or password. Please try again.');
document.getElementById('email').value = '';
document.getElementById('password').value = '';
}
}
// Wallet Section
function depositeMoney(){
var dip = parseInt(document.getElementById('diposite').value); // Getting the value from input field
if (document.getElementById('diposite').value.trim() == '' || dip<0){ //This is to ensure that user can't send empty value
document.getElementById('diposite').value = '';
alert('Please enter a valid number.');
return;
}
var currentAmount = parseInt(document.getElementById('current-wallet').innerText);
var totalDiposite = parseInt(document.getElementById('totaldeposite').innerText);
currentAmount += dip; //Adding current and new amount
totalDiposite += dip; //Adding total and new amount
document.getElementById('current-wallet').innerText = currentAmount;
document.getElementById('totaldeposite').innerText = totalDiposite;
document.getElementById('diposite').value = ''; //Clearing the input field
}
function withdrawMoney(){
var wit = parseInt(document.getElementById('withdraw').value); // Getting the value from input field
if (document.getElementById('withdraw').value.trim() == '' || wit<0){ //This is to ensure that user can't send empty value
document.getElementById('withdraw').value = '';
alert('Please enter a valid number.');
return;
}
var currentAmount = parseInt(document.getElementById('current-wallet').innerText);
var totalWithdraw = parseInt(document.getElementById('totalwithdraw').innerText);
if(wit > currentAmount){
alert('You have not enough money in your Wallet.')
document.getElementById('withdraw').value = '';
}
else{
currentAmount -= wit; //Substracting new amount from previous amount
totalWithdraw += wit; //Adding previous and new withdraw amount
document.getElementById('withdraw').value = ''; //Clearing the input field
}
document.getElementById('current-wallet').innerText = currentAmount;
document.getElementById('totalwithdraw').innerText = totalWithdraw;
}