Phone Number Validation

Hii All   I am working on a App where Contact Number . In formatting example it shows with dashes. So system should allow user to enter dashes. If in database field is numeric, then it should be formatted on the screen to include dashes and store in database only numbers.  How can I do this in my app.
2 answers

Maybe store the value in 2 fields, as string and a integer.

Let the user enter the data in the string field with an isMatch function use a regex that allows for the needed format.

When this is correct, then in a microflow take that input and remove all the non digit characters. For example if only dashes are allowed us something like ReplaceAll(attribute, '-', '') and store that value in the integer attribute.


You really don't want to use a numeric field to store a phone number. They are strings that happen to contain numbers.


This is what Google has to say about trying to store a phone number in a numeric type...


Never try to store phone numbers as an int or any other kind of numeric data type. You can't do arithmetic on them, and while 007, 07 and 7 are the same number they are not necessarily the same phone number - in some countries a leading 0 is significant and forms part of the number itself (see A leading zero in numbers formatted for domestic usage can always be discarded when dialing from abroad). Moreover, a phone number may contain other diallable characters (see Phone numbers contain only digits) or an extension portion, dialled after waiting for a tone.



It's best to store the phone number as a string in your application.