-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreditDebitCard.html
More file actions
144 lines (126 loc) · 5.22 KB
/
CreditDebitCard.html
File metadata and controls
144 lines (126 loc) · 5.22 KB
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
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/index.css" media="screen">
<link rel="stylesheet" type="text/css" href="css/signup.css" media="screen">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title> </title>
<script src="js/validator.js"></script>
<script>
window.onload = function(){
var creditCardForm = document.getElementById('creditCardForm');
creditCardForm.addEventListener('submit', function (event) {
var isInputNotEmpty = !validator.isEmpty(document.getElementById('hName').value) &&
!validator.isEmpty(document.getElementById('ccNumber').value) &&
!validator.isEmpty(document.getElementById('cvv').value) &&
!validator.isEmpty(document.getElementById('email').value) &&
!validator.isEmpty(document.getElementById('phone').value);
var isCvvValid = validator.isLength (document.getElementById("cvv").value, 4);
var isCcValid = validator.isCreditCard(document.getElementById('ccNumber').value);
var expYear = [document.getElementById("expYear").selectedIndex].value;
var expMonth = [document.getElementById("expMonth").selectedIndex].value;
var today = new Date();
var isExpired = false;
if(expYear < today.getYear())
isExpired = true;
else if
(expYear === today.getYear())
{
isExpired = today.getMonth() > expMonth;
}
event.preventDefault();
console.log(isInputNotEmpty + " isInputNotEmpty");
console.log(isCvvValid + " isCvvValid");
console.log(isCcValid + " isCcValid");
console.log(isExpired + " isExpired");
if ((isInputNotEmpty===false) || (isCvvValid===false) || (isCcValid===false) || (isExpired===false))
document.getElementById('creditCardForm').className = 'invalid'
else
{
console.log("in else");
document.getElementById('creditCardForm').className = 'valid';
}
});
}
</script>
</head>
<body>
<div class="header">
<h1>Tom Narainpursat</h1>
<h4>
Modern Front End Developer
</br>
<span class='quote'>"Where ever you go that's where you are"</span>
</h4>
</div>
<div class ='space'>
<div class='nav'>
<h3>Menu</h3>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="Button.html">Button</a></li>
<li><a href="SideBar.html">Profile Card</a></li>
<li><a href="Signup.html">Signup</a></li>
<li><a href="Search.html">Search</a></li>
<li><a href="Questionairre.html">Questionaire</a></li>
<li><a href="Login.html">Login</a></li>
<li><a href="Colours.html">Colour Builder</a></li>
<li><a href="ShippingBilling.html">Shipping & Billing</a></li>
<li><a href="CreditDebitCard.html">Payment Info</a></li>
<li><a href="Calculator.html">Calculator</a></li>
<li><a href="ProductListing.html">Products</a></li>
</ul>
</div>
<div id='content'>
<div class='form_main'>
<h1>Credit/Debit Card</h1>
<!--Signup Form Markup -->
<div class="form">
<form id = "creditCardForm">
<fieldset>
<label for="Name"><span>Card Holders Name</span><input type="text" class="input-field" name="hname" id="hName" /></label>
<label for="ccNumber"><span>Card Number</span><input type="text" class="input-field" name="ccnumber" maxlength="19" id="ccNumber" /></label>
<label for="cvv"><span>CVVC Number</span><input type="text" class="input-field" name="cvv" maxlength="4" id = "cvv" /></label>
<label for="expMonth"><span>Expiration Month</span>
<select name="expMonth" class="select-field" id = "expMonth">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</label>
<label for="expYear"><span>Expiration Year</span>
<select name="expYear" class="select-field" id = "expYear">
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
<option value="2025">2025</option>
<option value="2026">2027</option>
<option value="2028">2028</option>
<option value="2029">2029</option>
<option value="2030">2030</option>
<option value="2031">2031</option>
</select>
</label>
<label><input type="submit" value="Submit" /></label>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</body>
</html>