- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 07:50 AM
Hi Everyone,
Does anyone here know how to allow only numeric data in a single line field? Majority, we will use it in catalog item variables so we want it to be global function and we will just call the function if we want to use it using client script. Thanks and I appreciate your help!
Best Regards,
Diane Miro
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018
10:44 AM
- last edited on
‎01-30-2024
05:10 PM
by
ServiceNow
Hey Miro,
This is my script for accepting numbers only
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var regexp = /^[+]?\d*$/;
if(!regexp.test(newValue)){
alert('Please enter numeric value');
g_form.setValue('v_sec_review_unknown','');
}
}
in addition I defined "variable attributes max_length=3" to accept up to 3 digits
This is one of my sources:
You can also Refer:
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2020 08:13 AM
Hello , I know this solution is marked complete already but have a look at the OOB functionality as well in single line text field.
WHile creating a single line text variable you get a Type specification tab in that in Validation regex select Number and save the variable
Now whenever you are trying to put anything in the field apart from number it will give error...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2021 08:02 AM
How do you clear it if not a number in record producer OOB?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2022 08:43 AM
Wow nice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2022 05:33 AM
Hi, just go to the field --> Type Specifications and in the Validation Regex --> select number