I have a text area in my form which accepts all possible characters from user. i restrict the character count entered in the textarea to 10 . When the user enters a text with special character say `SampleTxt’ the character count in textarea is 10. But when i get the value of text area in the form, the text becomes SampleTxt
and the count of the text becomes 21. How to over come this issue?
function toCount(in) {
    var inObj=document.getElementById(in);
    var re='/\r\n|\n|\r\|\f/g';
    var i=0;
    while(re.match(inObj.value)){i++;}
    var length=characters - (inObj.value.length+i);
    if(length <= 0) {
        inObj.value=inObj.value.substr(0,characters);
document.getElementById("remcount").innerHTML = inObj.value.length;
        }
    }
Jsp
< html:textarea property="descTxt" styleId="desc" onkeyup="toCount('desc');" />
 
    