
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 04:12 AM
hi experts,
I set "Date" max length is 4, but in form layout it can input 15 ,why?
Solved! Go to Solution.
- Labels:
-
Instance Configuration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 04:55 AM
That's not possible. You can't restrict the user to add only 4 numbers. You could use the workaround Anurag and I mentioned, giving an error, maybe even do g_form.clearValue('u_date') to empty the field.
If really restricting the input, you can look at DOM manipulation. Though that's BAD PRACTICE. So not adviced.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 05:06 AM
you can make it read only if anyone try to enter more than 4 integer value. this is what you want ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 05:10 AM
better is when more than 4 integer value, not editable. if it impossible, just alert

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 05:11 AM
then whats wrong with the script which i have added. if you will enter more than 4 number it will instantly read only.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 05:11 AM
this is what i have .
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var date = g_form.getValue('u_num');
alert(date.length);
if(date.length >4) {
alert(' you can not add more than 4 number')
g_form.setReadOnly('u_num',true);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 05:36 AM
Thanks for your help.
>g_form.setReadOnly('u_num',true);
I think maybe it will be useful for me one day.