Validate a credit card number.
Option | Equivalent HTML attribute | Type | Description |
---|---|---|---|
message |
data-bv-creditcard-message |
String | The error message |
In addition to using the Luhn algorithm, the validator also validate the IIN ranges and length of credit card number.
It supports validating the following cards:
Type | Example | Result |
---|---|---|
American Express | 340653705597107 | |
Diners Club | 30130708434187 | |
Diners Club (US) | 5517479515603901 | |
Discover | 6011734674929094 | |
JCB | 3566002020360505 | |
Laser | 6304 9000 1774 0292 441 | |
Maestro | 6762835098779303 | |
Mastercard | 5303765013600904 | |
Solo | 6334580500000000 | |
Unionpay | ||
Visa | 4929248980295542 |
<form id="ccForm" class="form-horizontal">
<div class="form-group">
<label class="col-lg-3 control-label">Credit card number</label>
<div class="col-lg-5">
<input type="text" class="form-control" name="cc" />
</div>
</div>
</form>
<script>
$(document).ready(function() {
$('#ccForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
cc: {
validators: {
creditCard: {
message: 'The credit card number is not valid'
}
}
}
}
});
});
</script>
Comments
If you want to report a bug, please submit the issue on Github. Do NOT post the issue here.
For a general question or feedback, use the form below.