How to put a check on Empty TextField?
Str is empty i mean i enter nothing in TextFied even then it's going in else case NSString *Str= textField.text; NSLog(@"%@",开发者_Go百科Str);
if([Str isEqualToString:@""])
{
NSLog(@"Hi");
}
what about
if ( [string length] <= 0 )
use this
if(str == NULL)
you can use
if(!textField.text.length)
or
if([txtField.text isEqualToString:@""])
The Below code will check for the empty textfield and even for the whitespaces.
NSString *firstNameWithNoSpaces = [firstNameTxtField.text stringByReplacingOccurrencesOfString:@" " withString:@""];
if (![firstNameWithNoSpaces length] <= 0 ) {
}
you can also use this
if([textfield.text isEqualToString:@""] || textfield.text== nil )
精彩评论