Sabby
Sabby

Reputation: 2592

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 me out

Upvotes: 0

Views: 3559

Answers (2)

Swastik
Swastik

Reputation: 2425

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.

Upvotes: 5

AechoLiu
AechoLiu

Reputation: 18428

I think the regular expression can help you.

NSRegularExpression Class Reference

Upvotes: 1

Related Questions