// determine the legitimacy of the bank card number input // Parameters: Enter the bank card number to determine if the bank card number is a valid bank card number (YES is legal)-(BOOL) Checkcardno: (nsstring*) Cardno;
View Code determines the legitimacy interface of the bank card number input
#pragmaMark---—————————————————————————— determine the legitimacy of the bank card number input---——————————————————————————-(BOOL) Checkcardno: (nsstring*) cardno{intOddsum =0; intEvensum =0; intAllsum =0; intCardnolength = (int) [Cardno length]; intLastnum = [[Cardno substringfromindex:cardnolength-1] intvalue]; Cardno= [Cardno substringtoindex:cardnolength-1]; for(inti = cardnolength-1; i>=1; i--) {NSString*tmpstring = [Cardno substringwithrange:nsmakerange (i-1,1)]; intTmpval =[tmpstring Intvalue]; if(Cardnolength%2==1 ) { if((i%2) ==0) {Tmpval*=2; if(tmpval>=Ten) Tmpval-=9; Evensum+=Tmpval; }Else{oddsum+=Tmpval; } }Else{ if((i%2) ==1) {Tmpval*=2; if(tmpval>=Ten) Tmpval-=9; Evensum+=Tmpval; }Else{oddsum+=Tmpval; } }} allsum= Oddsum +evensum; Allsum+=Lastnum; if((allsum%Ten) ==0) returnYES; Else returnNO;}
View Code determines the legitimacy interface of the bank card number input
Determine the legitimacy interface of the bank card number input