Variable must contain 12 numeric characters and not allowed single space in variable regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Variable must contain 12 numeric characters and not allowed single space in variable regex
For example there are given only 4 spaces or 12 spaces on that time also not allowed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @mani55
Try with this:
^\d{12}$
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20m ago
Hi @mani55,
I'm not sure that the regex can physically stop a user from being able to type a space, however the OOTB number regex will produce an error message if any non-number characters are entered.
As an alternative approach, you could create an onChange client catalog script that will notify the user if they have not entered a specific minimum number of characters. For example:
Below is the script I used:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var minLength = 12; // Set your minimum character requirement here
if (newValue.length < minLength) {
g_form.showFieldMsg('your_variable_name', "Input must be at least " + minLength + " characters long.", 'error');
} else {
g_form.hideFieldMsg('your_variable_name'); // Clears the error once they type enough characters
}
}
If you haven't already, you can also set the maximum number of characters that can be entered by adding max_length=12 to the variable attribute to stop users from being able to enter too many characters.
☕ Powered by caffeine, curiosity, and more failed attempts than I'd like to admit