title: how to set range for textfield in swift
body: <p>I have 2 textfield which accepts month in MM formate, year in YYYY formate.I want to set range to textfield so that month textfield should accept only the value form 01-12 and year should accept valid four digit year.</p>
  
  <p>i have used the following code but it is not enough  it is not setting a range to month</p>
  
  <pre><code>func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -&gt; Bool
  {
      let maxLength = 4
      let currentString: NSString = textField.text
      let newString: NSString =
               currentString.stringByReplacingCharactersInRange(range, withString: string)
      return newString.length &lt;= maxLength
  }
  </code></pre>