Created
November 20, 2012 08:31
-
-
Save piaoapiao/4116739 to your computer and use it in GitHub Desktop.
check VerifyCode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSString *)checkVerifyCode:(NSString *)code | |
{ | |
code = [code stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
if([code isEqualToString:@""]) | |
{ | |
return @"验证码不能为空"; | |
} | |
NSString *verifyCodeRegex = [NSString stringWithFormat:@"([a-z,A-Z,0-9]{6})"]; | |
NSPredicate *verifyCodeTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", verifyCodeRegex]; | |
if ([verifyCodeTest evaluateWithObject:code]==NO) { | |
return @"请输入6位,数字,字母验证码"; | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment