How to validate email field in uitextfield in iphone
i would like to check that whether the field entered in the text field is email or not.If its email field then proceed else show some alert or error. I don't know how to validate that field. Please help m开发者_如何学编程e out
First add RegexKit
to your project.
Import RegexKitLite.h
to the class where you want to check the format
NSString *emailMatchstring=@"\\b([a-zA-Z0-9%_.+\\-]+)@([a-zA-Z0-9.\\-]+?\\.[a-zA-Z]{2,6})\\b";
compare this string to UITextField
's text.
I think the regular expression can help you.
NSRegularExpression Class Reference
精彩评论