viniciusmo/VMaskTextField

Pre-populate formatted phone text field

petec029 opened this issue · 3 comments

How do I pre-populate a phone formatted text field with a phone number I am storing online without any formatting characters?

For example userObj.phone = "2125551212"

When I try the following in viewDidLoad
phoneTextField.mask = @"(###) ###-####";
phoneTextField.text = userObj.phone;

My screen displays 2125551212

When I try
phoneTextField.mask = @"(###) ###-####";
[phoneTextField shouldChangeCharactersInRange:NSMakeRange(0, phoneTextField.text.length) replacementString:userObj.phone];

My screen displays
(125) 121-2125551212

Thanks man,
I will fix it.

Did you come up with a fix for formatting a pre-populated phone number text field?

Please use this method setTextWithMask available in version 1.0.4