JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<input type='text' id='ccType' name='ccType'/>
<ul style="list-style-type: none;" class="cards">
<li class="visa"></li>
<li class="visa_electron"></li>
<li class="mastercard"></li>
<li class="maestro"></li>
</ul>
</div>
<div class="form-group">
<label class="control-label">Card Number</label>
</div>
<div class="fake-input">
<input type="text" placeholder="Card Number" id="ccnumber" name="ccnumber" class="form-control tokenex_data"/>
<img id="cc" src="" width=30 />
</div>
CSS
.fake-input { position: relative; }
.fake-input input { border:none: background:#fff; display:block; width: 100%; box-sizing: border-box }
.fake-input img { position: absolute; top: 9px; right: 5px }
/*!
* Bootstrap v3.0.0
*
* Copyright 2013 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
*/
/*! normalize.css v2.1.0 | MIT License | git.io/normalize */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
audio,
canvas,
video {
display: inline-block;
}
audio:not([controls]) {
display: none;
height: 0;
}
[hidden] {
display: none;
}
html {
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
margin: 0;
}
a:focus {
outline: thin dotted;
}
a:active,
a:hover {
outline: 0;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
abbr[title] {
border-bottom: 1px dotted;
}
b,
strong {
font-weight: bold;
}
dfn {
font-style: italic;
}
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
mark {
background: #ff0;
color: #000;
}
code,
kbd,
pre,
samp {
font-family: monospace, serif;
font-size: 1em;
}
pre {
white-space: pre-wrap;
}
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
small {
font-size: 80%;
}
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
img {
border: 0;
}
svg:not(:root) {
overflow: hidden;
}
figure {
margin: 0;
}
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
legend {
border: 0;
padding: 0;
}
button,
input,
select,
textarea {
font-family: inherit;
font-size: 100%;
margin: 0;
}
button,
input {
line-height: normal;
}
button,
select {
text-transform: none;
}
button,
html...
JavaScript
(function() {
var $,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
$ = jQuery;
$.fn.validateCreditCard = function(callback, options) {
var card, card_type, card_types, get_card_type, is_valid_length, is_valid_luhn, normalize, validate, validate_number, _i, _len, _ref, _ref1;
card_types = [
{
name: 'amex',
pattern: /^3[47]/,
valid_length: [15]
}, {
name: 'diners_club_carte_blanche',
pattern: /^30[0-5]/,
valid_length: [14]
}, {
name: 'diners_club_international',
pattern: /^36/,
valid_length: [14]
}, {
name: 'jcb',
pattern: /^35(2[89]|[3-8][0-9])/,
valid_length: [16]
}, {
name: 'laser',
pattern: /^(6304|670[69]|6771)/,
valid_length: [16, 17, 18, 19]
}, {
name: 'visa_electron',
pattern: /^(622018)/,
valid_length: [16]
}, {
name: 'visa',
pattern: /^(4|4026|417500|4508|4844|491(3|7))/,
valid_length: [16]
}, {
name: 'mastercard',
pattern: /^5[1-5]/,
valid_length: [16]
}, {
name: 'maestro',
pattern: /^(5018|5877|502[1-3]|5020|5038|6304|5|6|6759|676[1-3])/,
valid_length: [12, 13, 14, 15, 16, 17, 18, 19]
}, {
name: 'maestro',
pattern: /^(6011|622018|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,
valid_length: [19]
}, {
name:'sbi_maestro',
pattern: /^(622018)/,
valid_length: [19]
}
];
if (options == null) {
options = {};
}
if ((_ref = options.accept) == null) {
options.accept = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = card_types.length; _i < _len; _i++) {
card = card_types[_i];
_results.push(card.name);
}
...