Open Bilal-Abdeen opened 1 year ago
I found a solution.
// I NEED HELP WITH THE ALGORITHM FOR THIS CASE
if (text?.startsWith("+")) {
// return [/(\+|00)[1-9][0-9 \-\(\)\.]{7,32}/]; // wrong
// accepts a "+" sign followed by a maximum of 19 characters, each of which is a digit, a space, a dash, a dot or a parenthesis.
return ['+', /[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,/[0-9 -().]/,];
}
Thank you very much for the excellent library. I am trying to develop a mask for phone numbers. I managed to cover all cases for local (in Australia) phone numbers. However, I am struggling to handle the situation when the user enters an international phone number (starting with a + sign). I think handling validation for different international numbers would be pretty complex.
So, I thought of using a simple, minimal validation
(\+)[1-9][0-9 \-\(\)\.]{7,32}
: If the 1st character is +, the user can enter any combination of (numbers, spaces, hyphens, dots, and/or parentheses). How can I code this into a mask function?