- 2020-03-30 04:07:32
Recently, I encountered such a problem in a project. I had to count the text entered by the user in the text box, which is shown below. Because we are a short message sending platform, now our country's short message service, if your message is more than 70 characters, the message will be sent to you in two messages. So we were asked to show the user how many words he typed. So that the user knows how many pieces of information I will give.
In the net a code, put up, began to use, ok, good, but after a period of use found a problem. Is after you delete the word, the above word count change has a problem, later studied, find the problem. OnKeyDown ="showLen(this)" onKeyUp="showLen(this) "used to use one of these methods at a time, and none of them were used, and both of them count when you press the keyboard and when you release the keyboard, okay, I'll put the program up