开发者

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 )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜