-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.js
executable file
·47 lines (40 loc) · 1.22 KB
/
payment.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
document.querySelector("form").addEventListener("submit", payment);
var paymentArr = JSON.parse(localStorage.getItem("paymentData")) || [];
function payment(event) {
event.preventDefault();
var email = document.getElementById("email").value;
var firstName = document.getElementById("firstname").value;
var lastName = document.getElementById("lastname").value;
var birthday = document.getElementById("birthdate").value;
var cardNo = document.getElementById("card-number").value;
var cvv = document.getElementById("card-cvv").value;
var month = document.getElementById("card-month").value;
var year = document.getElementById("card-year").value;
var paymentObj = {
email: email,
firstName: firstName,
lastName: lastName,
birthday: birthday,
cardNo: cardNo,
cvv: cvv,
month: month,
year: year,
};
paymentArr.push(paymentObj);
localStorage.setItem("paymentData", JSON.stringify(paymentArr));
if (
firstName !== "" &&
lastName !== "" &&
email !== "" &&
birthday !== "" &&
cardNo !== "" &&
cvv !== "" &&
month !== "" &&
year !== ""
) {
alert("Enter Otp = 1234");
window.location.href = "otp.html";
} else {
alert("Fill the details");
}
}