this is a method used to verify the bank card number in the input box. How to use this inspection rule in bootstrapValidaor to check
/ / verify bank card account
var bankAccount = function (bankno) {
var isChecked = false;
var n = /^[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]{0,2}\d{14,17}$/.test(bankno);
if (n) {
var lastNum = bankno.substr(bankno.length - 1, 1);//luhm
var first15Num = bankno.substr(0, bankno.length - 1);//1518
var newArr = new Array();
for (var i = first15Num.length - 1; i > -1; i--) {//1518
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; j < newArr.length; jPP) {
if ((j + 1) % 2 == 1) {//
if (parseInt(newArr[j]) * 2 < 9) {
arrJiShu.push(parseInt(newArr[j]) * 2);
} else {
arrJiShu2.push(parseInt(newArr[j]) * 2);
}
} else {//
arrOuShu.push(newArr[j]);
}
}
var jishu_child1 = new Array();//*2 >9
var jishu_child2 = new Array();//*2 >9
for (var h = 0; h < arrJiShu2.length; hPP) {
jishu_child1.push(parseInt(arrJiShu2[h]) % 10);
jishu_child2.push(parseInt(arrJiShu2[h]) / 10);
}
var sumJiShu = 0; //*2 < 9
var sumOuShu = 0; //
var sumJiShuChild1 = 0; //*2 >9
var sumJiShuChild2 = 0; //*2 >9
var sumTotal = 0;
for (var m = 0; m < arrJiShu.length; mPP) {
sumJiShu = sumJiShu + parseInt(arrJiShu[m]);
}
for (var n = 0; n < arrOuShu.length; nPP) {
sumOuShu = sumOuShu + parseInt(arrOuShu[n]);
}
for (var p = 0; p < jishu_child1.length; pPP) {
sumJiShuChild1 = sumJiShuChild1 + parseInt(jishu_child1[p]);
sumJiShuChild2 = sumJiShuChild2 + parseInt(jishu_child2[p]);
}
//
sumTotal = parseInt(sumJiShu) + parseInt(sumOuShu) + parseInt(sumJiShuChild1) + parseInt(sumJiShuChild2);
//Luhm
var k = parseInt(sumTotal) % 10 == 0 ? 10 : parseInt(sumTotal) % 10;
var luhm = 10 - k;
if (lastNum == luhm) {
isChecked = true;
} else {
isChecked = false;
}
} else {
isChecked = false;
}
return isChecked;
};
ACCOUNT: {
validators: {
notEmpty: { message: "" },
regexp: {
message: ""
}
}
},