I have a input text box maxlength 20
and use jquery auto count how many words left.
I have also use strlen
to check before it insert into DB
varchar(20)
(if too many characters, wont insert into DB), and htmlentities to prevent xss
Here is the problem, htmlentities will increase characters. So if auto count shows 17 but it actually over than 17 characters because htmlentities.
I don't want data truncate, any suggestion?