javascript - js verification, credit card vs. debit card?
ringa_lee
ringa_lee 2017-05-19 10:10:36
0
1
621

Do both credit cards and debit cards use this Luhm algorithm?
In the following paragraph, some card numbers seem to be unable to be determined correctly.
Who is doing something similar to this, can you provide the code? Thanks

//Description: Luhm verification of bank card number
//Luhm verification rules: 16-digit bank card number (19-digit universal):
// 1. Change 15 (or 18) without check digit ) card numbers are numbered from 1 to 15 (18) from the right, and the numbers on odd digits are multiplied by 2.
// 2. Add all the tens digits of the product of odd digits, plus all the numbers in the even digits.
// 3. Add the sum and the check digit to be divisible by 10.
//bankno is the bank card number banknoInfo is p or other controls that display prompt information

function luhmCheck(bankno){

var lastNum=bankno.substr(bankno.length-1,1);//取出最后一位(与luhm进行比较) var first15Num=bankno.substr(0,bankno.length-1);//前15或18位 var newArr=new Array(); for(var i=first15Num.length-1;i>-1;i--){ //前15或18位倒序存进数组 newArr.push(first15Num.substr(i,1)); } var arrJiShu=new Array(); //奇数位*2的积 <9 var arrJiShu2=new Array(); //奇数位*2的积 >9 var arrOuShu=new Array(); //偶数位数组 for(var j=0;j9 的分割之后的数组个位数 var jishu_child2=new Array();//奇数位*2 >9 的分割之后的数组十位数 for(var h=0;h9 的分割之后的数组个位数之和 var sumJiShuChild2=0; //奇数位*2 >9 的分割之后的数组十位数之和 var sumTotal=0; for(var m=0;m

}

ringa_lee
ringa_lee

ringa_lee

reply all (1)
PHPzhong

This new idea for algorithm verification is amazing. Was the original code written by a foreigner? Is it because the situation where the number of digits is 0 is not taken into account?

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!