Posted By

sag333ar on 03/28/11


Tagged

xcode Objective-c iphone NSPredicate NSArray ios iOS4 iPhone3 iPhone2


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

sag333ar


NSPredicate for TextLength & Email Validation


 / Published in: iPhone
 

URL: www.sagarrkothari.blogspot.com

  1. // predicates
  2. NSPredicate *nameTest;
  3. NSPredicate *mailTest;
  4.  
  5. nameTest = [[NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"[a-zA-Z0-9_]{5,}"] retain];
  6. mailTest = [[NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}"] retain];
  7. BOOL isNameOK=[nameTest evaluateWithObject:txtSignUpUserName.text];
  8. BOOL isEmailOK=[mailTest evaluateWithObject:txtSignUpEmail.text];

Report this snippet  

You need to login to post a comment.