Is there a way to set a character minumum on a multiline field? lets say I need a Business Justification for a request, but I am reciving to vauge of information. Is there a way that I could at least set the character minimum to 100?
Question
Question
Replies
You can do that with Javascript - this assumes your field has a CSS Class Name of myField:
$(document).ready(function () { $('.myField textarea').attr('minlength', 100); });
Sorry @████████ but that is not currently possible.
The Javascript in the new designer cannot directly modify the structure of fields within the form. You can only edit the parts of the field that have been made available within the LFForm interface. A quick perusal of the help documents for the changeFieldSettings function shows that this isn't one of the values that can currently be edited on fields.
Here's what we landed on using to accomplish this.
LFForm.onFieldChange(() => updateLength(), {fieldId: 34}); function updateLength () { const text = LFForm.getFieldValues({fieldId: 34}); const textLength = text.split(" ").length; LFForm.setFieldValues({fieldId: 57}, textLength); }
Where fieldId: 34 is the field I am trying to set the minimum word count on and fieldId: 57 is a new number field that is used to store the word count resulting from a function in the Laserscript.
After this Laserscript is configured correctly, I use Field rules to hide the submit button and show a custom HTML field that is used as an error message.
**Minimum character or word count would be nice to have built in. Or at least add the min and max Length functions to the changeFieldSettings Laserscript functions.
Bravo! Nice solution!