# Count and/or limit lines used in a multiline input field?

**URL:** <https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301>\
**Category:** Need help\
**Created:** [February 15, 2021, 6:20pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301 "2021-02-15T18:20:09Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![robert](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robert/32/149181_2.png) [@robert](https://forum.bubble.io/u/robert)\
**Post date:** [February 15, 2021, 6:20pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/1 "2021-02-15T18:20:09Z")

</div>

Rather than counting/limiting inputs by the number of characters, is it possible to count/limit by the number of lines used in a multiline input field?

---

<div class="post-metadata">

**Author:** ![cmarchan](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/cmarchan/32/253062_2.png) [@cmarchan](https://forum.bubble.io/u/cmarchan)\
**Post date:** [February 15, 2021, 6:27pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/2 "2021-02-15T18:27:49Z")

</div>

I will be interested to see how this could be approached.

Viewports can take on different widths and if your multiline input is set to be responsive … I do not see how this could be done.

Perhaps establishing a logic by which with a specific font, font size and fixating the MLI width you can infer how many lines (depending on characters count) have been inserted.

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [February 15, 2021, 6:38pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/3 "2021-02-15T18:38:16Z")

</div>

If by “lines” you mean “hard return” - i.e. someone hit the return key - as opposed to “soft wrapping”, then it seems doable, although it might require a little bit of “voodoo”. If I get a chance, I’ll experiment.

-Steve

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [February 15, 2021, 6:51pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/4 "2021-02-15T18:51:12Z")

</div>

> [@sudsy](#):
>
> If by “lines” you mean “hard return”…

If the above is the case, then this has already been solved for the most part. See [this post](http://forum.bubble.io/t/allow-users-to-upload-a-list-of-things/123358/6) and [this post](http://forum.bubble.io/t/multiline-input-into-list-of-texts/103281/3). Basically, using regex, convert the input into a list of strings using carriage return as the delimiter; and the number of lines will be the list item count.

If you need to take into account lines created by soft wrapping, then that’s a whole different animal, and nothing comes to mind right off the bat.

-Steve

---

<div class="post-metadata">

**Author:** ![robert](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robert/32/149181_2.png) [@robert](https://forum.bubble.io/u/robert)\
**Post date:** [February 15, 2021, 7:29pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/5 "2021-02-15T19:29:34Z")

</div>

Yes, a hard return. Thanks, @sudsy

The use case is for making sure the user doesn’t create a “comment” that extends beyond the printable area. This can be difficult if the user uses hard returns, thereby making a character count limit all but useless. I’ll look at the posts you referenced.

---

<div class="post-metadata">

**Author:** ![robert](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robert/32/149181_2.png) [@robert](https://forum.bubble.io/u/robert)\
**Post date:** [February 15, 2021, 7:32pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/6 "2021-02-15T19:32:01Z")

</div>

@cmarchan It’s a fixed width multiline input, so there is some level of predictability.

---

<div class="post-metadata">

**Author:** ![cmarchan](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/cmarchan/32/253062_2.png) [@cmarchan](https://forum.bubble.io/u/cmarchan)\
**Post date:** [February 15, 2021, 7:39pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/7 "2021-02-15T19:39:33Z")

</div>

Hi Robert,

Please review and advise

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/b/4/b41698b74647ca19fa55285eb745b1f6e8963ba8.png)

---

<div class="post-metadata">

**Author:** ![robert](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robert/32/149181_2.png) [@robert](https://forum.bubble.io/u/robert)\
**Post date:** [February 15, 2021, 8:21pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/8 "2021-02-15T20:21:02Z")

</div>

The problem is running off the printable area. Limiting the characters won’t prevent this if the user uses a lot of hard returns.

---

<div class="post-metadata">

**Author:** ![robert](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robert/32/149181_2.png) [@robert](https://forum.bubble.io/u/robert)\
**Post date:** [February 15, 2021, 9:29pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/9 "2021-02-15T21:29:06Z")

</div>

@sudsy Thanks. It works for counting the hard returns, but it doesn’t really solve the issue.

How about this…  
If I can size the multiline input field on the form to exactly match the print layout, could it be possible to…

1. with “Stretch to fit content” off, detect if the scroll bar is activated (meaning its beyond the natural dimensions of the input, or
2. with “Stretch to fit content” on, detect if the multiline input is being stretched?

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [February 15, 2021, 10:50pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/10 "2021-02-15T22:50:14Z")

</div>

Just to approach this from a slightly different perspective, would it solve the problem if you simply stripped the newlines out of the text that was entered? Or do you not want to modify what the user has input?

-Steve

---

<div class="post-metadata">

**Author:** ![robert](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robert/32/149181_2.png) [@robert](https://forum.bubble.io/u/robert)\
**Post date:** [February 16, 2021, 4:00am UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/11 "2021-02-16T04:00:18Z")

</div>

Trying to avoid modifying the users input. Want it to be WYSIWYG.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [April 26, 2021, 6:20pm UTC](https://forum.bubble.io/t/count-and-or-limit-lines-used-in-a-multiline-input-field/136301/12 "2021-04-26T18:20:42Z")

</div>

Closed on April 26, 2021, 6:20pm UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
