Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sujithkrishnan

macrumors 6502
Original poster
Hi...


Is there any EASY way to validate the texfields are empty or not ??

if (textfield.text ==nil) is valid only if i didnt tappped the textfield.
If a tap the textfield and dont enter anything textfield.text is not nil

Then i want to check for [textfield.text isEqaultoString@""]

So for a single textfield i want to check like following code...

Code:
if(textfield.text == nil)
ALERT: text empty
else if(textfield.text isEqualToString:@""])
ALERT:text empty
else
proceed

If i am giving if(textfield.text isEqualToString😡""]) alone also not enough..

Is there any other easy validation??? Or i want to write both conditions for all the textfields ????
 
Well you could combine your two tests safely as

Code:
if (textfield.text == nil || [textfield.text isEqualToString:@""])
{
// Empty
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.