
- 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 04:16 AM
Hi,
Max length is mostly for string fields. If you want a restriction on integer you can count the number of in a client script and throw error.
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 04:30 AM
hi Anurag,
could you show me how to achieve it ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 04:38 AM
Here is a sample script you can use in an onchange client script on the integer field
var x = g_form.getValue('<your integer field name>'); //
if(x.toString().length >4) {
//do something
}
else{
//do something
}
Please mark my answer correct/helpful if if helps you solve your issue.
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 04:49 AM
function onChange() {
var date = g_form.getValue('u_date');
if(date.toString().length >4) {
g_form.addErrorMessage('only input 4 bits');
} else {
}
}
this can pop up an error message and still can input data when its length>4 , but I want make it not edit when it length>4, how to achieve?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2019 04:54 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