You are viewing limited content. For full access, please sign in.

Question

Question

way to set multiline field character minimum in Forms

asked on March 5, 2021

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?

0 0

Replies

replied on March 5, 2021

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);
  
});

 

0 0
replied on January 4, 2024

Can someone convert this to be used in the new forms designer? ;)

0 0
replied on January 4, 2024

This is built into the new designer. You can set it on the Advanced tab for the field. I am not sure when it was added, but it is there for version 11.0.2307.40556.

replied on January 4, 2024

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.

0 0
replied on January 4, 2024

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.

4 0
replied on January 4, 2024

Bravo!  Nice solution!

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.