- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 05:24 AM - edited 08-23-2023 05:36 AM
Hi Everyone,
Need help in client script regex to allow only number form range 1 to 50000 in a single line text field.
Here is the regex I'm using and it is not working as expected. It allows till 50009. I want till 50000 only.
^(?:[1-9][0-9]?[0-9]?[0-9]?[0-9]?|1[1-5][0-9]?[0-9]?[0-9]?[0-9]?|2[0-4][0-9]?[0-9]?[0-9]?[0-9]?|25[0-5][0-9]?[0-9]?[0-9]?|6[0-4][0-9]?[0-9]?[0-9]?[0-9]?|50000)$
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 07:25 AM
This is working.
/^([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-9][0-9]{3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65000)$/;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 06:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 06:40 AM
@Saai1
Below regex, the key accepts a number from 1- 50000.
/^(?!5000[1-9]|0$|[5-9]\d{4}|[1-9]\d{5,})\d{1,5}$|^50000$/
range 1 to 65000 numbers
/^(?!6500[1-9]|0$|[5-9]\d{4}|[1-9]\d{5,})\d{1,5}$|^65000$/
I hope this helps!
Regards,
Hemant
**Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 06:49 AM
range 1 to 65000 numbers
/^(?!6500[1-9]|0$|[5-9]\d{4}|[1-9]\d{5,})\d{1,5}$|^65000$/
This is working from 1 to 49999 and also accepting 65000 but it is not accepting from 50000 to 64999.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 07:25 AM
This is working.
/^([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-9][0-9]{3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65000)$/;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 05:46 AM - edited 08-23-2023 05:47 AM
Hi @Saai1 Please find the below client script which fulfill your functionality
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var validNumberPattern = /^(?:[1-9]\d{0,4}|50000)$/;
if (!validNumberPattern.test(newValue)) {
g_form.addErrorMessage('Invalid Number', 'Please enter a number between 1 and 50000.');
g_form.setValue('description', ''); // Clear the field
}
}
Please, Mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Eswar Chappa