How to Validate phone Number...
BOOL value=[self validatePhone:[NSString stringWithFormat:@"%@",PhoneNumberTF.text]];
#pragma – mark PhoneNumber Validation Method
/**
PhoneNumber validation
@param phoneNumber => phoneNumber from phoneNumberTF text
@return => Bool
*/
-(BOOL)validatePhone:(NSString *)phoneNumber
{
NSString *phoneRegex = @"^((\\+)|(00))[0-9]{6,14}$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phoneRegex];
return [phoneTest evaluateWithObject:phoneNumber];
}
No comments:
Post a Comment