I don't know how开发者_运维百科 to use validations in iPhone, my requirement is in .Xib file Take 4textfields(username,password,confirmpassword,Age) and Click button.
Without entering the data in textfields click the button validations will work and display message like You have to enter username,password,conformpasswor,Age and password and conformpassword textfields must match.
There is no particular method like validate(textfield) in objective 'C' , so u have to use standard comparison methods for what you are trying to achieve like
if([username.text isEqualtoString:@""]||[password.text isEqualtoString:@""]||[cnfpassword.text isEqualtoString:@""]||[age.text isEqualtoString:@""])
{
// Show ur alert
}
if (![password.text isEqualtoString:cnfpassword.text])
{
//Show ur alert
}
if([textfild.text length] <= 0){
return false;
}
false
means you can set bool for this function and according to this you can decide to display alertiview.
Here I showed only one field you can specify for each within a single function which returns bool value to show alert.
精彩评论