title: Date and time masking with text field
body: <p>Hello everyone,</p>
  
  <p>I am working on a project where requirement is keypad should not pop up when we clicked on the text field as we are making number pad for the particular text field and we have succeed for doing this by..</p>
  
  <pre><code>- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
              if (textField == dateFld) {
  
                  UIView* dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
                 textField.inputView = dummyView;
        }  
  }
  </code></pre>
  
  <p>Now my problem is, I want to validate that text field to accept only particular format and limited number of input but i am unable to do this because the method for that is not getting called when we disabled the keypad to pop below is my code to validate the textfield.</p>
  
  <pre><code>- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  {
      //Format Date of Birth YYYY-MM-DD
      if(textField == dateFld)
      {
          if ((dateFld.text.length == 4)||(dateFld.text.length == 7))
              //Handle backspace being pressed
              if (![string isEqualToString:@""])
                  dateFld.text = [dateFld.text stringByAppendingString:@"-"];
          return !([textField.text length]&gt;9 &amp;&amp; [string length] &gt; range.length);
      }
      else
          return YES;
  
  }
  </code></pre>
  
  <p>Please help me to over come from this problem or any other way to do this.</p>
  
  <p>Thanks</p>