- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 12:07 AM
Hi SNOW users,
I have a Service catalog form with a single line text variable. I need to make it to accept only numerical values.
Is there any similar validation properties available for any of the variables in service catalog
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 12:50 AM
HI Andrew,
Have a look.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var number = g_form.getIntValue('u_quantity');
//if "Not a Number", clear the number value
if (isNaN(number)){
//number = "";
g_form.setValue('u_quantity','');
g_form.showFieldMsg('u_quantity','Please enter a valid integer number - stripping out non-numeric characters','info');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 02:25 AM
You can by making the client script run as an onChange script on this specific field.
As the others have said.
if (isNaN(newValue) || !isFinite(newValue) || newValue.indexOf('.') > -1) { //This if you only want whole numbers newValue.indexOf('.') > -1
g_form.showFieldMsg('field_name','Not a number','error');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 02:51 AM
Thanks every one it all worked.
thanks..