I'm using rich text editors (tiny_mce) pretty widely in a web application I'm developing. An issue I can't seem to get my head around is how to limit user input so that the length of generated content fits in my database field. Character counters, which I would normally use for non rich-text content, are pretty useless because the user does not see (or know or care about) the HTML being generated behind the scenes. i.e. If I limit the input to 100 characters and the user types 99 characters they will still likely exceed the character limit because of the html tags used to structure their content behind the scenes.
The options I see are:
- Do nothing and hope for the best. Obviously not really an option. There is a good chance that the insert will fail ungracefully when attempting to save to the db (mysql in this case).
- Validate the length of the generated HTML and provide user with a message if it exceeds allowed length. This will be confusing to the user who, to the best of his knowledge has met the requirements for text entry. Telling him that he has exceeded the limit when, in fact, he has only entered 99 characters, would only server to confuse/enrage
- Make the database field super large with the hope that it will never be exceeded. Seems like a bad idea...
This must be a commonly encountered issue. What is the best solution here?