Tuesday 15 March 2011

javascript - textarea maxlength attrribute and string length() inconsistencies -


Trying to write the number of characters remaining under one of the texts. When I add a lot of newlines, the following script does not work as expected: $ textarea.keyup (function () ($ div.text ("remaining characters:" + (parsiat) ($ Textarea.attr ("maxlength"), 10) - $ textarea.val (). Length));})

When too many are newline, the script reports more characters Available when I have not been able to write anything \ r \ n just trying to replace with \ n and then taking no advantage of the length of the string.

What's wrong? :)

EDIT: Only Chrome (latest - 27.0.1453.116) does not work as expected

  $ ('$ textarea'). Maxlength ({always show : True, pretext: 'remaining characters:', post text: ''});    

No comments:

Post a Comment