title: Validation on UITextField and phone number in iOS
body: <p>I have created 2 text Fields (Username and Phone number) when I executed my code, only text1(username) is getting executed. i got alert view, in the same way, i tried to give alert view that is text2(phone number) it must allow numeric numbers,
  but in my code  unable execute second if statement-text2 (phone number)   </p>
  
  <p>.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  @interface ViewController : UIViewController&lt;UITextFieldDelegate&gt;
  {
      __weak IBOutlet UITextField *text1;
      __weak IBOutlet UITextField *text2;
       IBOutlet UIAlertView *alert;
  }
  @property (weak, nonatomic) IBOutlet UITextField *text1;
  @property (weak, nonatomic) IBOutlet UITextField *text2;
  @property (strong, nonatomic) IBOutlet UIAlertView *alert;
  @end
  </code></pre>
  
  <p>.M</p>
  
  <pre><code>#import "ViewController.h"
  @interface ViewController ()
  @end
  @implementation ViewController
  {
      UIAlertView *prompt;
  }
  @synthesize text1;
  @synthesize alert;
  @synthesize text2;
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      text1.delegate = self;
      text2.delegate=self;
  }
  -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  {
      if(textField==text1)
      {
          NSCharacterSet *myCharSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
          for (int i = 0; i &lt; [string length]; i++)
          {
              unichar c = [string characterAtIndex:i];
              if (![myCharSet characterIsMember:c])
              {
                  alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"only number allowed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                  [alert show];
                  return NO;
              }
          }
          return YES;
      }
     if (textField==text2)
      {
          NSLog(@"GOOD day");
          NSCharacterSet *myCharSet1 = [NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"];
          for (int i = 0; i &lt; [string length]; i++)
          {
              unichar c1 = [string characterAtIndex:i];
              if (![myCharSet1 characterIsMember:c1])
              {
                  alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"number not  allowed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                  [alert show];
                  return NO;
              }
          }
      }
      return YES;
  }
  @end
  </code></pre>