-
Notifications
You must be signed in to change notification settings - Fork 1
/
paymentcard.html
144 lines (125 loc) · 3.92 KB
/
paymentcard.html
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
background-color:rgb(16,132,126);
margin:auto;
}
#container{
width: 100%;
height:auto;
/* border:1px solid red; */
display: flex;
justify-content: center;
align-items: center;
margin-top: 200px;
margin-bottom: 10px;
}
#cardnum,#cardname,#cardCVV{
width:250px;
padding: 15px;
margin-left:60px;
margin-bottom: 15px;
border-color: rgb(238, 231, 231);
}
#cardnum{
margin-top: 15px;
}
#button{
width:100px;
padding: 5px;
margin-top: 12px;
cursor: pointer;
margin-left: 150px;
}
form{
padding-top: 22px;
height:270px;
border:2px solid whitesmoke;
width: 400px;
background-color: rgb(250, 214, 214);
box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;
}
h1{
text-align: center;
margin-top: 70px;
margin-bottom: -90px;
font-size: 60px;
color: aliceblue;
line-height: 10px;
}
#p1{
padding-left: 70px;
margin-bottom: -20px;
}
#cardCVV{
margin-bottom: -10px;
}
</style>
</head>
<body>
<h1>Payment Page</h1>
<div id="container">
<form>
<input id="cardnum"type="number" value="" placeholder="Enter your card Number"/>
<br>
<input id="cardname" type="text" value="" placeholder="Enter Name on Card"/>
<br>
<input id="cardCVV" type="number" value="" placeholder="Enter your card CVV"/>
<p id="p1"></p>
<br>
<input id="button" type="submit" value="PAY"/>
</form>
</div>
</body>
</html>
<script>
document.querySelector("form").addEventListener("submit",mypaymentfun)
arrpay=JSON.parse(localStorage.getItem("pay"))||[]
function mypaymentfun(){
event.preventDefault();
var cardnum=document.querySelector("#cardnum").value
var cardname=document.querySelector("#cardname").value
var cardCVV=document.querySelector("#cardCVV").value
var obj={cardnumber:cardnum,
nameoncard:cardname,
CVV:cardCVV}
flag=0;
flag1=0;
flag2=0;
arrpay.map(function(ele){
if(cardnum.length==12 && cardname!="" && cardCVV.length==3){
flag=1;
}
if(cardnum!=12 || cardCVV!=3 ){
flag1=1;
}
if(cardnum.length=="" && cardname=="" && cardCVV.length==""){
flag2=1;
}
})
if(flag==1){
alert("Payment Successful")
window.location.href="homepage.html"
}
else {
if(flag1==1){
var a= document.querySelector("#p1")
a.innerHTML="Incorrect Data !"
a.style.color="Red"
}
if(flag2==1){
var a= document.querySelector("#p1")
a.innerHTML="Please Enter Details"
a.style.color="blue"
}
}
arrpay.push(obj)
localStorage.setItem("pay",JSON.stringify(arrpay))
}
</script>