Re: textfield validation / formatter: emailaddress
Re: textfield validation / formatter: emailaddress
- Subject: Re: textfield validation / formatter: emailaddress
- From: Keary Suska <email@hidden>
- Date: Tue, 02 Sep 2008 15:19:34 -0600
- Thread-topic: textfield validation / formatter: emailaddress
9/2/08 1:29 PM, also sprach email@hidden:
> is there any easy way to validate a textfield?
Yes. Multiple ways--NSFormatters, Key-Value Validation, and more.
> my app has a textfield, which should only accept emailaddresses.
>
> before I start reinventing the wheel, it's probably a good idea to ask here.
> google turned up nothing so far - maybe my searchterms -nstextfield formatter
> validation email- where wrong?
I doubt there are any out-of-the-box solutions for this. Someone may have
created a formatter/validator class, but you will have to watch out for
extensibility. It is probably just as easy to roll your own, but use known
patterns for email validation.
Generally, you need to wait for the entry to be complete before performing
validation. There is no way that I know of to determine the validity of a
part (other than allowed characters in the name part). Also, you can only
determine syntactical validity. You can't know whether an email is truly
valid.
To help the process you could have a formatter that simply doesn't allow the
entry of invalid characters, and to force case-folding, as well as some
basic prevention such as avoiding multiple @'s.
After the fact, you will be happier if you use a regular expression class to
test the overall syntax. You should be able to find examples online.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden