My textfield's content type is telephone number. It takes my phone number like 000-1234-1234. But my textfield is limited by string.count < 11. So I want remove dashes like 00012341234. How should I do?
Supplement: I can remove dashes after input number. But I want input removed number. When I tap suggest number textfield be filled none dashes number.
CodePudding user response:
You can simply remove the - symbol by using replacingOccurrences
:
let phoneNumber = "000-1234-1234"
let removeDashLine = phoneNumber.replacingOccurrences(of: "-", with: "")
print(phoneNumber)
result will be:
00012341234
CodePudding user response:
I use textFieldDidChange. Thank you