Verify the implementation code of the bank card number in JavaScript, and verify the javascript code
1. Introduce jquery. js first
2. Introduce luhmCheck. js // Luhm verification of the bank card number.
3. See the following case:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Below is the js
<Script type = "text/javascript"> function CheckBankNo (t_bankno) {var bankno = $. trim (t_bankno.val (); if (bankno = "") {$ ("# banknoInfo" ).html ("enter the bank card number"); return false;} if (bankno. length <16 | bankno. length> 19) {$ ("# banknoInfo" ).html ("the length of the bank card number must be between 16 and 19"); return false ;} var num =/^ \ d * $/; // full number if (! Num.exe c (bankno) {$ ("# banknoInfo" ).html ("bank card numbers must all be numbers"); return false ;}// the first six digits var strBin = ", 18, 30,35, 37,40, 41,42, 43,44, 45,46, 47,48, 5E, 51,52, 53,54, 55,56, 58,60, 62,65, 68,69, 84,87, 88,94, 95,98, 99. indexOf (bankno. substring (0, 2) =-1) {$ ("# banknoInfo" ).html ("the first six digits of the bank card number do not comply with the specifications"); return false ;} // Luhm check (new) if (! LuhmCheck (bankno) return false; $ ("# banknoInfo" ).html ("verified! "); Return true ;}</script>
Test card No:
1. 6222600810010710887
2. 6225881414207430
The above is the implementation code for verifying the bank card number in JavaScript introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!