Monday, 23 November 2015

User name with alphanumeric and underscore characters only check.

+ (BOOL)usernameCheck:(NSString *)string{

    NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_"];
    characterSet = [characterSet invertedSet];
    NSRange range = [string rangeOfCharacterFromSet:characterSet];
    if (range.location != NSNotFound) {
        return NO;
    }
    return YES;
}