How can i restriction the filed value by using client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 03:09 AM
Hi all,
I have requirement, can I restrict the field value by using client script.
thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2019 05:26 AM
Hi Amlan,
thank for your response, but I"m still Unable to stop the user from typing and at end user is getting error message post after going to next filed. i need to restrict user from typing when he is in control of same field.So it should be something different then regular client scripts.
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 03:20 AM
Hi JMR,
write onLoad client script to restict the field value,for detail go through below link:
https://community.servicenow.com/community?id=community_question&sys_id=44af0365dbdcdbc01dcaf3231f96198b
NOTE: Mark correct or helpful if it helps you.
Warm Regards,
Raj patel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 03:23 AM
if you need to restrict user from entering a value on particular field.
you can use UI policy to make that field read only, or use g_form.setReadOnly('VARIABLE NAME',true); in client scripts.
Using UI policy is preferred.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 04:09 AM
Hi satheesh kumar,
I am trying to restrict the filed values by using configure dictionary, but it is not allow because all ready some records is their. thus why i'm trying on change client scripts. i'm tried below code, but my point is user wants to enter only 10 character not more than.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// if(oldValue!=newValue)
var r=g_form.getValue('short_description');
var l=r.length;
if(l>10)
{
var t=r.slice(0,10);
g_form.setValue('short_description',t);
g_form.showFieldMsg('short_description','....................');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 09:19 AM
oh..ok. it is not possible to do this functionality. i too had faced this situation and followed the same onchange method and errror message
else
you need to create a macro/widget variable to do that.
check below link for more details
-satheesh