Adjust charsRemaining maxlength enforcement

Test value length before truncating to resolve issue with some browsers moving cursor