feature request: Improve SMS Sign-in: Auto-Detect Country Code via Regex Rules
What problem did you meet?
-
Currently, users can select any country code, but some apps need to restrict them (e.g., only +86 for China).
-
When browsers auto-fill a phone number (e.g., +8613912345678), users must: ◦ Delete +86 from the input ◦ Manually select +86 from the dropdown
Describe what you'd like Logto to have
• Allow admin-configurable regex rules for each country code. • When a user types/pastes a phone number:
- The system checks if the input matches any configured regex (e.g., ^+86(1[3-9]\d{9})$ for China).
- If matched, automatically select the correct country code and trim the prefix from the input.
- If multiple regexes match (e.g., +1 for US/Canada), apply the first matched rule in priority order.
These changes would greatly improve usability, especially for applications targeting specific regions. Thank you for your consideration!
Thanks for sharing this suggestion! We've added your feature request to our public roadmap where it is open for voting. Country code restrictions for phone input / Smart country code detection