我使用此代碼來檢查文本字段是否爲空。第一次,它會起作用,但當我更改文本字段值時,警報不起作用。驗證多個uitextfield
-(void)sendclick {
NSString *msg;
if(firstnametextfield.text==NULL) {
[email protected]"enter first name";
NSLog(@"%@",firstnametextfield.text);
}
else if(lastnametextfield.text==NULL) {
[email protected]"enter last name";
NSLog(@"%@",lastnametextfield.text);
}
else if(emailtextfield.text==NULL) {
[email protected]"enter email address";
NSLog(@"%@",emailtextfield.text);
}
else if(companytextfield.text==NULL) {
[email protected]"enter company name";
NSLog(@"%@",companytextfield.text);
}
else if(phonetextfield.text==NULL) {
[email protected]"enter phone numper";
NSLog(@"%@",phonetextfield.text);
}
else {
[email protected]"register success fully";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:msg delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
}
很容易檢查文本提交,感謝您的幫助 – NANNAV