Most of the projects have this requirement to apply validations OR add Country Code as prefix to Phone Number based on the Country. This approach makes use of most of the OOB methods to achieve this.
- On Account Entity create a field to capture the formatting “Phone Number Format”
- Configure the Input Mask control for Phone Number field as below.
From form editor -> field properties -> Controls, Select Input Mask control
In the Mask Properties, Select “Bind to a value on a field” and select the field created in Step-1 (Phone Number Format)
3. Create a new Entity for Country and create a field “Phone Number Format” to store Phone Number formats for each country.
Guideline for formatting:
0 – Digit
9 – Digit or space
#– Digit, sign, or space
L – Letter
I – Letter or space
A – Alphanumeric
A – Alphanumeric or space
< – Converts characters that follow to lower case
– Converts characters that follow to upper case
| – Disables case conversion
\ – Escapes any character, turning it into a literal
All others – Literals
(This field can be hidden if user’s don’t want to see it)
5. When user tries to enter value other than specified in the mask, Error message is shown like below. Also, it allows you to type characters only as specified in the Mask format. (In our example, you can only type in digits but cannot type in alphabet / special characters in the remaining 10 places.)