question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Counter is incorrect when you paste text

See original GitHub issue

In your demo for textarea, type some text with line breaks in it. Copy it and than kept press Ctrl + V to repeatedly paste the text and you can see the counter is wrong. Fix this issue and it will make it a good plugin 😃 Here is how you can do: https://github.com/aaronrussell/jquery-simply-countable/blob/master/jquery.simplyCountable.js#L123

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dvelayoscommented, Apr 29, 2015

i think it’s a problem counting line breaks as 2 chars instead of 1

0reactions
41GitHubcommented, Jun 26, 2017

When you paste text in that is too long, the remaining variable becomes a negative number. When subtracting a negative the result goes positive. Check if remaining is less than zero and set remaining to zero if it is.

maxLengthIndicator.html(updateMaxLengthHTML(currentInput.val(), maxLengthCurrentInput, (maxLengthCurrentInput - remaining)));

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQuery - char counter doesn't work with paste event
Show activity on this post. I wrote a jQuery character counter, it works when I type, but not when text is pasted. The...
Read more >
Control the formatting when you paste text - Microsoft Support
Follow these steps to turn it on. Go to File > Options > Advanced. In the Cut, copy, and paste section, select Show...
Read more >
Wrong hyperref with repeated counter - LaTeX Stack Exchange
This is because the target of a hyperlink is based on the counter value. If the counter is reset then there is a...
Read more >
Error occurred while manually uploading COUNTER 5 reports ...
Incorrect Formatting. This error usually indicates that the data within the file you are uploading is incorrectly formatted or corrupt.
Read more >
WordCounter - Count Words & Correct Writing
Copy and paste your text into the online editor to count its words and characters, check keyword density, and correct writing mistakes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found