- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2020 03:33 AM
Hello All,
I am trying to restrict single line text variable limit to 40 numbers with the help of RegEX (^[1-4]?[0]$|^[1-3]?[0-9]$)
like field will not accept any character and it will receive only digit minimum 1 hours and maximum 40 hours.
Solved! Go to Solution.
- Labels:
-
Incident Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2020 03:59 AM
Hi,
Correct me if I am wrong.
What you need is Variable value should between 1-40 not 40 lengths value.
If yes then have onChange client script on that variable.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var val=g_form.getValue('variable name'); //enter correct variable name
if(val<0 && val>40){
g_form.setValue('variable name',''); //enter correct variable name
}
}
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 04:57 AM
Hi
Your if condition is wrong it should be
if(val>0 && val<=40)
Please don't mark wrong code responses as right answer.
Thanks
Sudhanshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 05:03 AM
What is wrong can you explain?
If value is less than 0 and greater than 40 then I am clearing that value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 05:04 AM
Oh i miss ""
That's right
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 05:06 AM
Value between 1-40 will be acceptable;
And I think you need to check your else condition. Your else condition is looks wrong because if value is between 1-40 then you are clearing the field.
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 05:11 AM
Ohh yaa I see just now!