ios - UItextField Phone number formatting -
i have 3 text fields called home phone,work phone , mobile phone. need validation , number formatting these fields. below shown condition.
the home phone , work phone text fields should not accept more 10 digits , less 8 digits. fields should accept numbers. format of numbers should xxxx-xxxx(if 8 digits) xx-xxxx-xxxx(if 10 digits)
the mobile phone number field should not accept more 10 digits. fields should accept numbers. format of numbers should xxxx-xxx-xxx
i not sure how achieve this. please me.
i think can achieve doing following:
- capture text change event in uitextfield. add dashes after 4 characters, after 7 characters , on depending on format want.
- use regular expression validate entire string of numbers dashes. (eg: xxxx-xxxx format use '[0-9]{4}-[0-9]{4}')
Comments
Post a Comment