1

How can I format a users text field input as they type and insert a "-" or " " on every 5th character.

4500000000000000 becomes 4500 0000 0000 0000

  • Duplicate of [Formatting a UITextField for credit card input like (xxxx xxxx xxxx xxxx)](http://stackoverflow.com/questions/12083605/formatting-a-uitextfield-for-credit-card-input-like-xxxx-xxxx-xxxx-xxxx) – Mark Amery Oct 05 '13 at 11:22

1 Answers1

1

Make a delegate for your text field, then implement -textField:shouldChangeCharactersInRange:replacementString: to update the text field whenever the user types / pastes anything.

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005