how to limit the character on the multi line text catalog variable?

Mada11
Tera Contributor

Hi,

how to limit the character on the multi line text catalog variable?

6 REPLIES 6

@Mada11 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ashish Parab
Mega Sage

Hello @Mada11 ,

 

You can create an onChange client script as below.

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   //Type appropriate comment here, and begin script below
   var charLimit = 250;
   var field_value= g_form.getValue('field_value'); // use backend value of your variable

   if (field_value.length > charLimit){
		g_form.setValue('field_value', field_value.substring(0, charLimit));
		g_form.addFieldMessage('field_value', 'Maximum character limit exceeded. Please limit your input to ' + charLimit + ' characters.');
        return false;
   }else{
        g_form.clearMessages();
        return true;
   }
}

 

Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.

 

Thanks and Regards,

Ashish