- 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-17-2024 10:41 PM
Hello,
Please check below link:
It clearly mentions that max_length is only applicable on single line text and wide single line text variable types.
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 10:42 PM
So can you suggest me other way please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 10:49 PM - edited ‎04-17-2024 10:49 PM
Hello,
You can try below client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var text = newValue;
var textlen = text.length;
if(textlen >=250){
g_form.showFieldMsg('your variable name','Your message exceeds 250 character length','error');
g_form.clearValue('your variable name');
}
}
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-18-2024 12:50 AM
Not working