I have 1 UITextfield for password in my iPhone application.
I want to validate this textfield with the following validation.
for me Best way was to use NSPredicate and regex.
this is regex for your case: ^(?=.{10,})(?=.*[0-9])(?=.*[a-zA-Z])([@#$%^&=a-zA-Z0-9_-]+)$
objective C code:
NSString *regex = @"^(?=.{10,})(?=.*[0-9])(?=.*[a-zA-Z])([@#$%^&=a-zA-Z0-9_-]+)$";
NSPredicate *passwordTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
BOOL isValid = [passwordTest evaluateWithObject:yourTextfield.text];