-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (51 loc) · 2.28 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Credit card regex</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<style>
#form{
margin-top: 300px;
}
</style>
</head>
<body>
<div class="page-header">
<h1>Regex library<small>This example will validate a visa card. (All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13).</small></h1>
</div>
<form class="navbar-form navbar-left" role="search" action="javascript:void(0)">
<div class="form-group">
<input id="card-number" type="text" class="form-control" placeholder="insert credit card number">
</div>
<button type="submit" class="btn btn-default">Submit</button>
<p></p>
</form>
<!--Panel-->
<section class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">Regex list</div>
<div class="panel-body">
//Regex<br/>
var visa = /^4[0-9]{12}(?:[0-9]{3})?$/;//All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13.<br/>
var masterCard = /^5[1-5][0-9]{14}$/;//All MasterCard numbers start with the numbers 51 through 55. All have 16 digits.<br/>
var amex = /^3[47][0-9]{13}$/;//American Express card numbers start with 34 or 37 and have 15 digits.<br/>
var discover = /^6(?:011|5[0-9]{2})[0-9]{12}$/;//Discover card numbers begin with 6011 or 65. All have 16 digits.<br/>
var cvv = /^[0-9]{3,4}/;//Credit cards security code. from 3 to 4 digits<br/>
//Example<br/>
function validate(visa){<br/>
var creditcard = 4561321465477895;<br/>
if(creditcard.match(visa)) {<br/>
alert("This is a valid credit card number");<br/>
} else{<br/>
alert("Error: This credit card is invalid");<br/>
}<br/>
}<br/>
</div>
</div>
</section>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="regex.js" type="text/javascript"></script>
</body>
</html>