Set condition on MLI character limit

I have a multiline input and I’d like to change the character limit when a state is changed. Is this possible?
Limit # of characters

Hi there, @sydney22… I don’t believe you can set the max number of characters via a condition on a multiline input element. That being said, you could do something like disable a submit button or show an alert or something when a custom state is set to a certain value and the multiline input’s value’s number of characters is greater than a certain number of characters. Does that sound like something that could work for you?

Best…
Mike

1 Like

Thanks, @mikeloc that’s a reasonable workaround. I was originally hiding and showing separate MLIs with different character counts, but the workflows and conditionals became unwieldy for such a simple objective.

1 Like

I had to do something like this with my app. I set a state which was the length of the text and if the state was set, my “save” button got disabled. But I was also able to click save even when I entered in too much text IF I was fast enough.

Your suggestion would work fine, but I would also suggest adding a workflow so that if the save button is clicked AND the text length is too long, then tell the user it’s too much text (just to be extra safe).

1 Like

Maximum Number of Characters is not an attribute you can change via a condition in vanilla Bubble…

However, if you don’t mind getting your hands dirty with a bit of simple JavaScript, it’s very simple to do…

Just add an ID Attribute to your input element (for example ‘input’), then run the following simple JavaScript (using the Toolbox Plugin) any time you want to change the Input’s character limit:

document.getElementById('input').maxLength = 200 (or whatever value you want to set as the new max character length)

Here’s a working example:

Dynamic Max Length (bubbleapps.io)

1 Like

This seems like the cleanest way to do it. Thanks, @adamhholmes!

1 Like