mirror of
https://github.com/zhigang1992/RETableViewManager.git
synced 2026-05-14 16:19:27 +08:00
Restrict user to type month more than 12
This commit is contained in:
@@ -302,4 +302,17 @@ static inline NSString * RECreditCardType(NSString *creditCardNumber)
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
||||
if (textField == self.expirationDateField) {
|
||||
if (range.location == 1) {
|
||||
NSInteger month = [NSString stringWithFormat:@"%@%@", self.expirationDateField.text, string].integerValue;
|
||||
if (month > 12) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user