Restrict additional comments field to accept only 4000 characters

Pandu3
Tera Contributor

Hi Team,

 

The requirement is to restrict the additional comments(Journal Input - field type) field to accept only 4000 characters on case record. Can anyone please help me how to achieve this requirement. Thanks in advance. I have written onChange client script on case table,

 

Script:  //testing purpose I'm trying to restrict 4 characters only

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

var v_comments = g_form.getValue('comments');
var count = v_comments.length;
if (count > 5) {
alert("No.of characters " + count);
g_form.setValue('comments', v_comments.substring(0, 4));
}

}

 

Pandu3_0-1697806573024.png

 

still it is allowing to enter 5th character but the requirement is to stop allowing the 5th character.

 

Thanks! 

11 REPLIES 11

Samaksh Wani
Giga Sage
Giga Sage

Hello @Pandu3 

 

use this script :-

 

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

var v_comments = g_form.getValue('comments');
var count = v_comments.length;
if (count > 5) {
alert("No.of characters " + count);
return false;
}

}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

return false for an onChange? I am believing you meant onSubmit.

Hi @Samaksh Wani , no luck!

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Script seems fine, what exaclty is the issue?