How to terminate the string characters in service now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 08:39 AM
Hi Team,
we trying to restricting the use for 20 characters for note field ,So we written client script onChange .we need to stop typing after 20 character and show an alert .but user enter more than 20 characters also ,Script not showing any alert
Below Is my code :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
var dec = g_form.getValue('notes');
// Calculate the byte length of the string using TextEncoder
var byteLength = new TextEncoder().encode(dec).length;
if (byteLength > 20) {
alert("notes length exceeds 4000 bytes');
return false;
}}
Please guide me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 11:53 PM
Hi @String ,
The other way would be via DOM Manipulation which we cannot suggest. Also not a good practice. So whatever solution suggested by fellow community experts plz go with that.
Thanks,
Danish