one, (check format) function Checkbankno (t_bankno) {var bankno = $.trim (T_bankno); if (Bankno = = "") {layer.msg ("Please fill in the bank card number"); return false;} if (Bankno.length < | | bankno.length >) {layer.msg ("bank card number must be between 16 and 19"); return false;} var num =/^\d*$/; Full Digital if (!num.exec (Bankno)) {layer.msg ("bank card number must be all numbers"); return false;} Start with 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) {layer.msg ("bank card number beginning 6 bits not conforming to specification"); return false;} LUHM Check (new) var lastnum=bankno.substr (bankno.length-1,1);//Take Out the last one (compare with Luhm) var first15num=bankno.substr (0, BANKNO.LENGTH-1);//The first 15 or 18-bit var newarr=new array (); for (Var i=first15num.length-1;i>-1;i--) {///15 or 18-bit reverse-deposit into the array Newarr.push (First15num.substr (i,1));} var arrjishu=new Array (); The <9var arrjishu2=new Array () of odd digits * *; The >9var arroushu=new Array () of odd digits * *; An even-bit array for (Var j=0;j<newarr.length;j++) {if (j+1)%2==1) {//odd digit if (parseint (Newarr[j]) *2<9) ARRJIshu.push (parseint (newarr[j)), Else Arrjishu2.push (parseint (newarr[j]) * *);} else//even digit Arroushu.push (newarr[j]);} var jishu_child1=new array ();//Odd digit * * >9 after the partition of the array single-digit var jishu_child2=new array ();//ODD digits * * * >9 the array after the split 10-digit for (Var h=0 ; h<arrjishu2.length;h++) {Jishu_child1.push (parseint (arrjishu2[h])%10); Jishu_child2.push (parseint (arrjishu2[h])/10);} var sumjishu=0; The sum of the array of odd digit < 9 and Var sumoushu=0; The sum var sumjishuchild1=0 of an even-bit array; Odd Digit * * >9 after the partition of the array of single-digit and VAR sumjishuchild2=0; Odd Digit * * >9 after the partition of the array 10-digit and Var sumtotal=0;for (var m=0;m<arrjishu.length;m++) {Sumjishu=sumjishu+parseint ( Arrjishu[m]);} for (Var n=0;n<arroushu.length;n++) {sumoushu=sumoushu+parseint (arroushu[n]);} for (Var p=0;p<jishu_child1.length;p++) {sumjishuchild1=sumjishuchild1+parseint (jishu_child1[p]); Sumjishuchild2=sumjishuchild2+parseint (Jishu_child2[p]);} Calculate sum Sumtotal=parseint (Sumjishu) +parseint (Sumoushu) +parseint (sumJiShuChild1) +parseint (sumJiShuChild2);// Calculate Luhm value var k= parseint (sumtotal)%10==0?10:paRseint (sumtotal)%10;var luhm= 10-k;if (lastnum==luhm) {return true;} else{layer.msg ("bank card number does not conform to the specification"); return false;}}
Second, (enlarge when input)//1, CSS: zoomed-in style<style>.inputcard-wrap {position:relative;}. Inputcard-wrap. panelcard {display:none;position:absolute;top:- 30px;left:79px;z-index:100; border:1px #ffce6e solid;padding:10px;height:8px;font-size:1.7em;line-height:8px;color: #585858;} </style>//2, Content:<div class= "Divfirst inputcard-wrap" > Bank card number: <input type= "text" name= "Bankcardnumber" class= "Input-text Size-S Inputcard "id=" Bankcardnumber "style=" margin-left:5px; "placeholder=" Enter bank card number "><div class=" PanelCard "></ Div></div>//3, JS: <script>$ (function () {/* Bank card number real-time verification magnified display */$ (". Inputcard"). KeyUp (function (e) {var self = $.trim (e.target.val UE), parent = $ (e.target). Closest (". Inputcard-wrap"), panel = $ (". Panelcard", parent), val = Self.replace (/\d/g, "); (Self.length > 19) {this.value = self.substr (0, 19); return this.value;} if (val = = self) {panel.show (); val = self.replace (/(...) (?=.) /g, ' $ '); Panel.html (val);} else {panel.hide (); return self;}); $ (". Inputcard"). Unbind (' Focusin '); $ (". Inputcard"). Bind (' Focusin ', function (e) {var self = $.trim (e.target.value), Parent = $ (e.target). Closest (". Inputcard-wrap"), panel = $ (". Panelcard", parent), val = Self.replace (/(...) (?=.) /g, ' $ '); if (val! = ") {panel.show (); Panel.html (val);}}); $ (". Inputcard"). Unbind (' Focusout '); $ (". Inputcard"). Bind (' Focusout ', function (e) {var parent = $ (e.target). Closest (" . Inputcard-wrap "), panel = $ (". Panelcard ", parent); Panel.hide ();});}) </script>
JS Check bank card number, input card number amplification effect