title: How to limit the amount of characters in 5 UITextFields
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/433337/iphone-sdk-set-max-character-length-textfield">iPhone SDK: Set Max Character length TextField</a>  </p>
  </blockquote>
  
  
  
  <p>I have 5 UITextFields, where only 6 characters should be allowed. How can I limit the input to just 6 characters per text field? Any other code I tried failed and I didn't found a way of fixing it, thanks :D
  <strong>EDIT:</strong> This is the codes I tested:</p>
  
  <pre><code>-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  {
      NSUInteger newLength1 = [serie1.text length] + [string length] - range.length;
      NSUInteger newLength2 = [serie2.text length] + [string length] - range.length;
      NSUInteger newLength3 = [serie3.text length] + [string length] - range.length;
      NSUInteger newLength4 = [serie4.text length] + [string length] - range.length;
      NSUInteger newLength5 = [serie5.text length] + [string length] - range.length;
  
      if(newLength1 &gt; 6)
          return NO;
      if(newLength2 &gt; 6)
          return NO; 
      if(newLength3 &gt; 6)
          return NO; 
      if(newLength4 &gt; 6)
          return NO; 
      if(newLength5 &gt; 6)
          return NO;
  
      return YES;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  {
      if(serie1.text.length &gt;= 6 &amp;&amp; range.length == 0) {
          return NO;
  
      }
      if(serie2.text.length &gt;= 6 &amp;&amp; range.length == 0) {
          return NO;
  
      }
      if(serie3.text.length &gt;= 6 &amp;&amp; range.length == 0) {
          return NO;
  
      }
      if(serie4.text.length &gt;= 6 &amp;&amp; range.length == 0) {
          return NO;
  
      }
      if(serie5.text.length &gt;= 6 &amp;&amp; range.length == 0) {
          return NO;
  
      }
      return YES;
  }
  </code></pre>
  
  <p>Both have the problem that when you write 6 characters then you cannot write anymore on any other text field until you delete the characters you wrote</p>