- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
{
NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string];
UITextField *loginPass = _textArr[1];
if (loginPass == textField) {
if ([toBeString length] > 12) {
textField.text = [toBeString substringToIndex:12];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"长度不能超过12" delegate:nil cancelButtonTitle:@"ok"
otherButtonTitles:nil, nil];
[alert show];
return NO;
}
}
return YES;
}
UItexfile实时验证输入字符,布布扣,bubuko.com
时间: 2024-12-21 13:15:09