• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Validate a user entry
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Validate a user entry


  • Subject: Validate a user entry
  • From: Michèle Garoche <email@hidden>
  • Date: Wed, 19 Dec 2001 05:58:42 +0100

From a newbie:

In Travel Advisor in Learning Cocoa, there is a field validation implemented as follow:

- (void)awakeFromNib
{
...
[currencyRateField setDelegate:self];
...
}

- (BOOL)control:(NSControl *)control isValidObject:(id)obj
{
if (control == currencyRateField)
{
if ([obj floatValue] <= 0.0)
{
NSRunAlertPanel(@"Travel Advisor",
@"Rate cannot be zero or negative.", nil, nil, nil);
return NO;
}
}
return YES;
}

It works only (not surprisingly) when the user enters a value in the field.

Should I implement a second method so that it works also when the user tabs through the field without entering a value. Which method and how to implement it ?

And a third one when the user adds the record (in case he did not even go into the field). Again which method and how to implement it.

Any help would be greatly appreciated.


  • Follow-Ups:
    • Re: Validate a user entry
      • From: Jens Bauer <email@hidden>
    • Re: Validate a user entry
      • From: "Craig S. Cottingham" <email@hidden>
  • Prev by Date: Re: Drawing faster with NSImage???
  • Next by Date: Delete record
  • Previous by thread: Go to next record in table view
  • Next by thread: Re: Validate a user entry
  • Index(es):
    • Date
    • Thread