Interactive online courses HTML Academy
2026-03-09 14:05 Diff

The tool for checking the new comment now works fine: if the text in the input field is longer than 142 characters, then you will see an error message and the button to submit the comment will be locked. But if you reduce the length of the text, then the lock will be lifted and the error message will disappear. Our problem now is that the character counter will not reset after the comment is submitted.

This happens because the oninput handler is not triggered when we submit the form and clear the input field. To make the comments work as they should, assign the value 0 to the text content of the counter inside another event handler (onsubmit). It already exists in our script. We worked with it before in the previous chapter. The instructions inside this handler are executed when the form is submitted. Therefore, when the user submits a new comment, the counter will be reset to zero. Make sure that this is the case!