1, first introduced jquery.js
2, followed by the introduction of Luhmcheck.js//bank card number Luhm check
3, look at the following case:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Here is JS
<script type= "Text/javascript" >
function Checkbankno (t_bankno) {
var bankno = $.trim (T_bankno.val ()); c3/> if (Bankno = = "") {
$ ("#banknoInfo"). HTML ("Please fill in the bank card number");
return false;
}
if (Bankno.length < | | bankno.length >) {
$ ("#banknoInfo"). HTML ("bank card number length must be between 16 to 19");
return false;
}
var num =/^\d*$/; Full digit
if (!num.exec (Bankno)) {
$ ("#banknoInfo"). HTML ("bank card number must be all numbers");
return false;
}
The opening 6-bit
var strbin = " 10,18,30,35,37,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,62,65,68,69,84,87,88,94,95,98,99 ";
if (Strbin.indexof (bankno.substring (0, 2)) = = 1) {
$ ("#banknoInfo"). HTML ("the bank card number at the beginning of 6-bit does not conform to the specification");
return false;
}
Luhm Checksum (new)
if (!luhmcheck (bankno)) return
false;
$ ("#banknoInfo"). HTML ("Validate through!");
return true;
}
</script>
Test Card number:
1, 6222600810010710887
2, 6225881414207430
The above is a small set to introduce the JavaScript commander of the code to check the bank card number, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!