0

So i'm trying to build a script that will essentially count the line breaks in an inputed text field and then use a validator to check if the data inputed has too many rows. For example this could be the input:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nisl eros, 
pulvinar facilisis justo mollis, auctor consequat urna. Morbi a bibendum metus. 
Donec scelerisque sollicitudin enim eu venenatis. Duis tincidunt laoreet ex, 
in pretium orci vestibulum eget. Class aptent taciti sociosqu ad litora torquent
per conubia nostra, per inceptos himenaeos. Duis pharetra luctus lacus ut 
vestibulum. Maecenas ipsum lacus, lacinia quis posuere ut, pulvinar vitae dolor.
Integer eu nibh at nisi ullamcorper sagittis id vel leo. Integer feugiat 
faucibus libero, at maximus nisl suscipit posuere. Morbi nec enim nunc. 
Phasellus bibendum turpis ut ipsum egestas, sed sollicitudin elit convallis. 
Cras pharetra mi tristique sapien vestibulum lobortis.

Here there would be 10 new lines of text. Currently I'm struggling to find a solution to this issue. Any advice would be greatly appreciated.

Thanks!!

rtwhite
  • 399
  • 1
  • 3
  • 8
  • 1
    _"to check if the data."_ To check if the data _what_? – Wyck Sep 30 '20 at 20:01
  • 1
    Does this answer your question? [How to count the number of lines of a string in javascript](https://stackoverflow.com/questions/8488729/how-to-count-the-number-of-lines-of-a-string-in-javascript) – Wyck Sep 30 '20 at 20:02
  • sorry edited the text. I found that earlier the problem is if you were to copy and paste my example into the working example here http://jsfiddle.net/C8CaX/ it does not output the correct number of rows unfortunately – rtwhite Sep 30 '20 at 20:23
  • 1
    Works for me: http://jsfiddle.net/21d79ngc/ – Wyck Sep 30 '20 at 20:26
  • So weird, it didn't the first time I tried lol. Thanks for your response its much appreciated! – rtwhite Sep 30 '20 at 21:32

0 Answers0