限制汉字长度
NSString * ISNAME = @"^[\u4E00-\u9FA5]{2,4}$"; //2-4个汉字
NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", ISNAME];
if ([regextestmobile evaluateWithObject:_tf2_xingming.text] == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告" message:@"请输入正确的姓名" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
return;
}

浙公网安备 33010602011771号