 <p>Set the delegate of the text field to you controller class, implement the <code>UITextFieldDelegate</code> protocol and put your formatting code in the <code>textField:shouldChangeCharactersInRange:replacementString:</code> method.</p>