Javascript Validation Part 8 ( Various Card Validations)
Validation Part 8 ( Various Card Validations)
- <html >
<head>
<title>JavaScript form validation - checking non-empty</title>
<style type="text/css">
li
{
list-style-type: none;
font-size: 16pt;
}
.mail
{
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
width: 400px;
background: #D8F1F8;
border: 1px soild silver;
}
.mail h2
{
margin-left: 38px;
}
input
{
font-size: 20pt;
}
input:focus, textarea:focus
{
background-color: lightyellow;
}
input submit
{
font-size: 12pt;
}
.rq
{
color: #FF0000;
font-size: 10pt;
}
</style>
<script type="text/javascript">
function cardnumber(inputtxt) {
var cardno = /^(?:4[0-9]{12}(?:[0-9]{3})?)$/;
if (inputtxt.value.match(cardno)) {
return true;
}
else {
alert("Not a valid Visa credit card number!");
return false;
}
}</script>
</head>
<body onload='document.form1.text1.focus()'>
<div class="mail">
<h2>
Input Credit Card No.[Starting with 4 length 13 or 16 digits (Visa) and Submit]</h2>
<form name="form1" action="#">
<ul>
<li>
<input type='text' name='text1' /></li>
<li> </li>
<li class="submit">
<input type="submit" name="submit" value="Submit" onclick="cardnumber(document.form1.text1)" /></li>
<li> </li>
</ul>
</form>
</div>
</body>
</html>
- <html>
<head>
<title>JavaScript form validation - checking non-empty</title>
<style type="text/css">
li
{
list-style-type: none;
font-size: 16pt;
}
.mail
{
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
width: 400px;
background: #D8F1F8;
border: 1px soild silver;
}
.mail h2
{
margin-left: 38px;
}
input
{
font-size: 20pt;
}
input:focus, textarea:focus
{
background-color: lightyellow;
}
input submit
{
font-size: 12pt;
}
.rq
{
color: #FF0000;
font-size: 10pt;
}
</style>
<script type="text/javascript">
function cardnumber(inputtxt) {
var cardno = /^(?:(?:2131|1800|35\d{3})\d{11})$/;
if (inputtxt.value.match(cardno)) {
return true;
}
else {
alert("Not a valid JCB card number!");
return false;
}
}</script>
</head>
<body onload='document.form1.text1.focus()'>
<div class="mail">
<h2>
Input Credit Card No.[Starting with 2131 or 1800, length 15 digits or starting with
35, length 16 digits (JCB card) and Submit</h2>
<form name="form1" action="#">
<ul>
<li>
<input type='text' name='text1' /></li>
<li> </li>
<li class="submit">
<input type="submit" name="submit" value="Submit" onclick="cardnumber(document.form1.text1)" /></li>
<li> </li>
</ul>
</form>
</div>
</body>
</html>
- <html><head>
<title>JavaScript form validation - checking non-empty</title>
<style type="text/css">
li
{
list-style-type: none;
font-size: 16pt;
}
.mail
{
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
width: 400px;
background: #D8F1F8;
border: 1px soild silver;
}
.mail h2
{
margin-left: 38px;
}
input
{
font-size: 20pt;
}
input:focus, textarea:focus
{
background-color: lightyellow;
}
input submit
{
font-size: 12pt;
}
.rq
{
color: #FF0000;
font-size: 10pt;
}
</style>
<script type="text/javascript">
function cardnumber(inputtxt) {
var cardno = /^(?:6(?:011|5[0-9][0-9])[0-9]{12})$/;
if (inputtxt.value.match(cardno)) {
return true;
}
else {
alert("Not a valid Discover card number!");
return false;
}
}</script>
</head>
<body onload='document.form1.text1.focus()'>
<div class="mail">
<h2>
Input Credit Card No.[Starting with 6011, length 16 digits or starting with 5, length
15 digits (Discover) and Submit</h2>
<form name="form1" action="#">
<ul>
<li>
<input type='text' name='text1' /></li>
<li> </li>
<li class="submit">
<input type="submit" name="submit" value="Submit" onclick="cardnumber(document.form1.text1)" /></li>
<li> </li>
</ul>
</form>
</div>
</body>
</html>
- <html >
<head>
<title>JavaScript form validation - checking non-empty</title>
<style type="text/css">
li
{
list-style-type: none;
font-size: 16pt;
}
.mail
{
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
width: 400px;
background: #D8F1F8;
border: 1px soild silver;
}
.mail h2
{
margin-left: 38px;
}
input
{
font-size: 20pt;
}
input:focus, textarea:focus
{
background-color: lightyellow;
}
input submit
{
font-size: 12pt;
}
.rq
{
color: #FF0000;
font-size: 10pt;
}
</style>
<script type="text/javascript">
function cardnumber(inputtxt) {
var cardno = /^(?:3(?:0[0-5]|[68][0-9])[0-9]{11})$/;
if (inputtxt.value.match(cardno)) {
return true;
}
else {
alert("Not a valid Dinners Club card number!");
return false;
}
}</script>
</head>
<body onload='document.form1.text1.focus()'>
<div class="mail">
<h2>
Input Credit Card No.[starting with 300 through 305, 36, or 38, length 14 digits
(Diners Club) and Submit</h2>
<form name="form1" action="#">
<ul>
<li>
<input type='text' name='text1' /></li>
<li> </li>
<li class="submit">
<input type="submit" name="submit" value="Submit" onclick="cardnumber(document.form1.text1)" /></li>
<li> </li>
</ul>
</form>
</div>
</body>
</html>
- <html >
<head>
<title>JavaScript form validation - checking non-empty</title>
<style type="text/css">
li
{
list-style-type: none;
font-size: 16pt;
}
.mail
{
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
width: 400px;
background: #D8F1F8;
border: 1px soild silver;
}
.mail h2
{
margin-left: 38px;
}
input
{
font-size: 20pt;
}
input:focus, textarea:focus
{
background-color: lightyellow;
}
input submit
{
font-size: 12pt;
}
.rq
{
color: #FF0000;
font-size: 10pt;
}
</style>
<script type="text/javascript">
function cardnumber(inputtxt) {
var cardno = /^(?:3[47][0-9]{13})$/;
if (inputtxt.value.match(cardno)) {
return true;
}
else {
alert("Not a valid Amercican Express credit card number!");
return false;
}
}</script>
</head>
<body onload='document.form1.text1.focus()'>
<div class="mail">
<h2>
Input Credit Card No.[Starting with 34 or 37, length 15 digits (American Express)
and Submit</h2>
<form name="form1" action="#">
<ul>
<li>
<input type='text' name='text1' /></li>
<li> </li>
<li class="submit">
<input type="submit" name="submit" value="Submit" onclick="cardnumber(document.form1.text1)" /></li>
<li> </li>
</ul>
</form>
</div>
</body>
</html>
- <html >
<head>
<title>JavaScript form validation - checking non-empty</title>
<style type="text/css">
li
{
list-style-type: none;
font-size: 16pt;
}
.mail
{
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
width: 400px;
background: #D8F1F8;
border: 1px soild silver;
}
.mail h2
{
margin-left: 38px;
}
input
{
font-size: 20pt;
}
input:focus, textarea:focus
{
background-color: lightyellow;
}
input submit
{
font-size: 12pt;
}
.rq
{
color: #FF0000;
font-size: 10pt;
}
</style>
<script type="text/javascript">
function cardnumber(inputtxt) {
var cardno = /^(?:5[1-5][0-9]{14})$/;
if (inputtxt.value.match(cardno)) {
return true;
}
else {
alert("Not a valid Mastercard number!");
return false;
}
}
</script>
</head>
<body onload='document.form1.text1.focus()'>
<div class="mail">
<h2>
Input Credit Card No.[Starting with 51 through 55, length 16 digits (Mastercard)
and Submit</h2>
<form name="form1" action="#">
<ul>
<li>
<input type='text' name='text1' /></li>
<li> </li>
<li class="submit">
<input type="submit" name="submit" value="Submit" onclick="cardnumber(document.form1.text1)" /></li>
<li> </li>
</ul>
</form>
</div>
</body>
</html>
No comments:
Post a Comment