#pragma mark -判断是否是邮箱
+(BOOL)validateEmail:(NSString*)email
{
NSString*emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate*emailTest = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTestevaluateWithObject:email];
}
#pragma mark -判断银行卡号是否正确
+(BOOL)checkCardNo:(NSString*)cardNo{
intoddsum =0;//奇数求和
intevensum =0;//偶数求和
intallsum =0;
intcardNoLength = (int)[cardNolength];
intlastNum = [[cardNosubstringFromIndex:cardNoLength-1]intValue];
cardNo = [cardNosubstringToIndex:cardNoLength -1];
for(inti = cardNoLength -1; i>=1;i--) {
NSString*tmpString = [cardNosubstringWithRange:NSMakeRange(i-1,1)];
inttmpVal = [tmpStringintValue];
if(cardNoLength %2==1){
if((i %2) ==0){
tmpVal *=2;
if(tmpVal>=10)
tmpVal -=9;
evensum += tmpVal;
}else{
oddsum += tmpVal; }
}else{
if((i %2) ==1){
tmpVal *=2;
if(tmpVal>=10)
tmpVal -=9;
evensum += tmpVal;
}else{
oddsum += tmpVal; } } }
allsum = oddsum + evensum;
allsum += lastNum;
if((allsum %10) ==0)
returnYES;
else
returnNO; }
#pragma mark -验证是否是手机号
+(BOOL)checkPhoneNumInput:(NSString*)mobile
{
NSString* MOBILE =@"^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$";
NSString* CM =@"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\\d)\\d{7}$";
NSString* CU =@"^1(3[0-2]|5[256]|8[56])\\d{8}$";
NSString* CT =@"^1((33|53|8[09])[0-9]|349)\\d{7}$";
// NSString * PHS = @"^0(10|2[0-5789]|\\d{3})\\d{7,8}$";
NSPredicate*regextestmobile = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@", MOBILE];
NSPredicate*regextestcm = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@", CM];
NSPredicate*regextestcu = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@", CU];
NSPredicate*regextestct = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@", CT];
BOOLres1 = [regextestmobileevaluateWithObject:mobile];
BOOLres2 = [regextestcmevaluateWithObject:mobile];
BOOLres3 = [regextestcuevaluateWithObject:mobile];
BOOLres4 = [regextestctevaluateWithObject:mobile];
if(res1 || res2 || res3 || res4 ){
returnYES;
}else{
returnNO;}
}