Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

1
  • 2
    One quick addition: in order to truly enforce a character max using this method, you need to specify the max character limit in the slice call, not just -1. Although -1 will take out the very last character in the text area, if you get close to the limit and then hold down a bunch of keys all at once, you can get more characters in because the slice won't happen until keyup. So for a very hard limit, use $(this).val($(this).val().slice(0, 1000)); Commented Jul 30, 2015 at 20:40