0

I have question. I used editable plugin in octobercms project. I can't find this in documentation. How can I limit the length of the characters in my content in html. If there is no any way so how can I do this with JavaScript? I tried to use code like this but I am low in JavaScript.

var x = document.getElementById('gallery');
  var tekst= x.outerText;
  console.log(tekst);
  console.log(x.outerText.length);
  if (x.outerText.length > 150) {

  var trimmedString = tekst.substring(0, 150);
 document.getElementById('gallery').outerText = trimmedString;
  }

But now this text not use dic and classes and editable. What can I do to fix this?

Adrian
  • 5
  • 1
  • 6

2 Answers2

0

Maybe you should do it in the HTML instead.

<form action="demo_form.asp">
  Username: <input type="text" name="usrname" maxlength="10"><br>
  <input type="submit" value="Submit">
</form>

http://www.w3schools.com/tags/att_input_maxlength.asp

Danieboy
  • 4,393
  • 6
  • 32
  • 57
  • Alternatively, check this out. http://stackoverflow.com/questions/2867479/limiting-number-of-characters-in-a-contenteditable-div – Danieboy Jul 28 '16 at 08:59
  • this is not input this is document which i can editable with plugin – Adrian Jul 28 '16 at 09:00
0

you can just put maxlength="10" for maxlength it will stop the cursor for input after 10 characters.

jitendra varshney
  • 3,484
  • 1
  • 21
  • 31