- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 07:16 AM
Hi All,
we will restrict phone regex
We will allow digits with dashes in between, but the dashes could be optional.
Example: 555555555 or 555-555-555 (no leading zero)
Currently we have the following regex:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var regex = /^[1-9][0-9]{0,29}$/; // regex for phone numbers
How can we solve this? Could you please help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 03:52 AM
Hi @BuriB,
I've tweaked it slightly and tested it to ensure it works as required:
(Please note, the 4 highlighted in bold in the ending brackets it the number used to determine the minimum and maximum number. So in using the regex as shown below you can have 9 minimum (3+3+3) and 10 maximum (3+3+4). If you want to extending this to 11 numbers for example, change the 4 to a 5.)
/^[1-9]{3}(-)?\d{3}(-)?\d{3,4}$/gm;
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 05:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 05:13 AM
Hi @Robbie ,
we are very close now - when we can allow that we can enter Zero after the first digit and length can up to 30 digits in total, then we got it.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 05:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 02:39 AM
Hi @BuriB , you can try the following regex:
/^[1-9]\d{2}(-)?[1-9]\d{2}(-)?[1-9]\d{2}$/
Thanks,
Aryan Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 03:52 AM
Hi @BuriB,
I've tweaked it slightly and tested it to ensure it works as required:
(Please note, the 4 highlighted in bold in the ending brackets it the number used to determine the minimum and maximum number. So in using the regex as shown below you can have 9 minimum (3+3+3) and 10 maximum (3+3+4). If you want to extending this to 11 numbers for example, change the 4 to a 5.)
/^[1-9]{3}(-)?\d{3}(-)?\d{3,4}$/gm;
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie