
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2018 07:03 AM
Greetings folks
I'm needing to set a specific character limit to a multi-line text field of a form variable. I've seen some other articles about this, but most are older and I am concerned that there may be better ways to do this now, and being an utter novice at writing code I have no idea how to actually script it.
The stuff I have tried cobbling together gives me errors galore when I try to build a catalog client script:
So as you can see I'm fairly crap when it comes to coding at this time.
Any suggestions will be mightily appreciated.
Cheers
A.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2018 01:07 PM
No, like this...
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;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2018 01:14 PM
AH HA!
That's why I had the var name messed up... much to learn have I.
Thank you for your patience and guidance Mark!
It is much appreciated!