Here I am again, I was noticing that when a user enters their telephone number there is no “control”, in the sense that I live in Italy, and our numbers are 10 numbers long and have a prefix +39, example +39 123 456 7890 , I would like when someone signs up not to be able to enter random numbers (even just one number allows you to proceed), but first the prefix and then that the number must be exactly 10 numbers, and if this condition is not respected a hint or However I can’t continue, can you help me?
A quick and dirty method is to use a number entry component and set the minimum and maximum values to encompass the range of phone numbers you would accept.
Anything more robust would require a custom form and regex to validate the phone number.
I had already tried with minimum and maximum but maybe I’m wrong with the values and it gives me this error
don’t pay attention to hint, I inserted it initially because I didn’t know how to “guide” the user to enter his number correctly.
if so is it difficult to create this regex? how could I do ?
I thought of this type of solution
^+39\s\d{3}\s\d{3}\s\d{4}$
I’m using a check text matches in the table with this formula but it doesn’t work, am I doing something wrong?
alternatively I thought of this for this type of entry +391234567890
^+39\d{9}$
but it doesn’t work anyway, maybe I’m doing something wrong…
I worked a bit and came to a solution!
the number must be entered like this +393894375928 and here is what I used:
^(?:(?:+|00)\d{2,3}|0)\s*1-9{4}$
Now it works correctly, I’m sharing it for anyone who may need it!
I also found another solution that accepts this type of input:
393894375928
39 3894375928
+393894375928
+39 3894375928
I’ll share the regex code with you:
^(?:+?39)?\s3\d{9}$|^(?:+?39)?\s0\d{9,10}$
The regex is going to be a better solution overall, especially with the country code. But just stepping back to the min/max idea for a bit…your numbers were much too low. What I meant was along the lines of 1000000000 - 9999999999 for your min and max if you were only considering the 10 digit number without the country code.
Min and Max is not the number of digits. It’s that actual lowest and highest acceptable number.
thanks so much this is a better solution for me!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.