 <pre><code>- (BOOL) textFieldShouldReturn:(UITextField *)textField { //resign the keypad and check if 10 numeric digits entered... NSRange range; range.length = 3; range.location = 3; textField.text = [NSString stringWithFormat:@"(%@) %@-%@", [textField.text substringToIndex:3], [textField.text substringWithRange:range], [textField.text substringFromIndex:6]; } </code></pre>