Download
User Rating: 0/5 ( 0 votes)
Smart Validate is a jQuery credit card validation plugin, that makes credit card format validation a simple task. It ensures that user has entered valid credit card number before making actual transaction. Smart Validate supports the following credit cards.
-
American Express
-
Master Card
-
Visa Card
-
Diners Club
-
Discover
Source: egrappler.com
1. INCLUDE JS AND CSS FILES
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="ccvalidate.js" type="text/javascript"></script>
<link href="ccvalidate.css" rel="stylesheet" type="text/css" />
2. HTML
<div class="cc-container">
<select id="cc-types" class="cc-ddl-type">
<option value="mcd">Master Card</option>
<option value="vis">Visa Card</option>
<option value="amx">American Express</option>
<option value="dnr">Diner Club</option>
<option value="dis">Discover</option>
</select>
<input type="text" id="card-number" class="cc-card-number" />
<input type="submit" value="Checkout" class="cc-checkout" id="check-out" />
</div>
Add the code below to your HTML document or use classes “cc-ddl-type”, “cc-card-number” and “cc-checkout” to existing elements. These classes are mandatory as the smart validate plugin uses these classes to read the required values.
3. JAVASCRIPT
$(document).ready(function() {
$('.cc-container').ccvalidate({
onvalidate: function(isValid) {
if (!isValid) {
alert('Incorrect Credit Card format');
return false;
}
}
});
});