Implementation effect: Force users to enter only 16 digits, here is the use of credit card number input.
Enter the number of characters greater than 16, the color of the word to black, and no matter what continues to enter what content, only take the first 16 bits;
If it is less than 16 bits, the color of the word is set to red, and the setting is "invalid".
-(void) viewdidload{ [Super Viewdidload]; Check input box every 0.1 seconds [Nstimer scheduledtimerwithtimeinterval:0.1 target:self selector: @selector (checkcardinfoinput) Userinfo:nil Repeats:yes];}
-(void) checkcardinfoinput{ BOOL isValid = YES; if ([Self.cardNumberTextField.text length] >=) { Self.cardNumberTextField.textColor = [Uicolor blackcolor]; Self.cardNumberTextField.text = [Self.cardNumberTextField.text substringwithrange:nsmakerange (0, +)]; } else{ self.cardNumberTextField.textColor = [Uicolor redcolor]; IsValid = NO; } Other authentication if (isValid = = YES) {self . addcreditcardbutton.enabled = YES; Self. Addcreditcardbutton.backgroundcolor = [Uicolor greencolor]; } else{self . addcreditcardbutton.enabled = NO; Self. Addcreditcardbutton.backgroundcolor = [Uicolor graycolor]; }}