- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 10:35 PM
I Want to set the character limit to 250 chars on multi-text variables but when I'm using max_length=250 in variable attribute it is not working
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 11:06 PM
HI @Akki8219
Try to this code
function onSubmit() { var maxLength = 290; // Add desired max length here var varName = 'full_description'; // Add variable name here var multi = g_form.getValue(varName); var len = multi.length; if(len > maxLength){ var str = multi.slice(0, maxLength); g_form.setValue(varName, str); g_form.showFieldMsg(varName, 'Max length of ' + maxLength.toString() + ' exceeded for this field.', 'error'); return false; } }
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 12:54 AM
Hello,
It is working on my instance.
Please share screenshots from your script. Make sure onchange field is the multi line text variable.
If my answer helped you in any way please mark it as correct or helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 11:06 PM
HI @Akki8219
Try to this code
function onSubmit() { var maxLength = 290; // Add desired max length here var varName = 'full_description'; // Add variable name here var multi = g_form.getValue(varName); var len = multi.length; if(len > maxLength){ var str = multi.slice(0, maxLength); g_form.setValue(varName, str); g_form.showFieldMsg(varName, 'Max length of ' + maxLength.toString() + ' exceeded for this field.', 'error'); return false; } }
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 12:50 AM
not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 01:43 AM
Hi @Akki8219 ,
For single line text and single line long text field the limit can be set using attriutes but for multiline text you need to use the onchange client scipt like below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var maxLength = 250; // Add desired max length here
var varName = 'max_length'; // Add variable name here
var multi = g_form.getValue(varName);
var len = multi.length;
if(len > maxLength){
var str = multi.slice(0, maxLength);
g_form.setValue(varName, str);
g_form.showFieldMsg(varName, 'Max length of ' + maxLength.toString() + ' exceeded for this field.', 'error');
}
}
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....