我使用此代码检查文本字段是否为空。第一次,它会起作用,但是当我更改文本字段值时,警报不起作用。
-(void)sendclick {
NSString *msg;
if(firstnametextfield.text==NULL) {
msg=@"enter first name";
NSLog(@"%@",firstnametextfield.text);
}
else if(lastnametextfield.text==NULL) {
msg=@"enter last name";
NSLog(@"%@",lastnametextfield.text);
}
else if(emailtextfield.text==NULL) {
msg=@"enter email address";
NSLog(@"%@",emailtextfield.text);
}
else if(companytextfield.text==NULL) {
msg=@"enter company name";
NSLog(@"%@",companytextfield.text);
}
else if(phonetextfield.text==NULL) {
msg=@"enter phone numper";
NSLog(@"%@",phonetextfield.text);
}
else {
msg=@"register success fully";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:msg delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
}