views:

36

answers:

1

I have a problem with jquery.charcounter.js its not counting returns as /r/n its counting them as 1 char instead of 3 or 4 here is the code is there a way around it

            if (el.val().length > max) {
            el.val(el.val().substring(0, max));
            if (settings.pulse && !p) {
                pulse(container, true);
            };
        };
+2  A: 

This really has nothing to do with jQuery or even charcounter, the .length property is purely javascript. As far as I know, \n is always counted as 1 character rather than two. I'm not sure what issue you're running into from this, but you may want to read this post:

http://stackoverflow.com/questions/462348/string-length-differs-from-javascript-to-java-code

Colin
+1 I was about to post the same thing about javascript length.
Jim Schubert
Thank you, you pointed me in the right direction , on the serverside i had to check whether the field was more then 1000 chars if it was the find and replace any \r\n with \n
Howlingfish