0

I have textarea with maxlength attribute i.e. maxlength="20". After entering 10 ENTER keys it stops entering any characters while maxlength is 20 in CHROME BROWSER. If you want to test this issue then open here and hit ENTER key 10 times.

<textarea row="10" cols="10" maxlength="20"></textarea>   

Note: Enter characters with ENTER key and see.

Sandy
  • 6,285
  • 15
  • 65
  • 93
  • Why does the linked fiddle has nothing to do with your question? – feeela Sep 18 '12 at 12:11
  • If I try `` in Chromium it let me enter 20 chars. Opera doesn't respect this attribute. – feeela Sep 18 '12 at 12:13
  • If you hit ENTER key then it allow you to hit ENTER key only 10 times in Google chrome. – Sandy Sep 19 '12 at 05:10
  • 1
    This Question has already been answered here: http://stackoverflow.com/questions/10030921/chrome-counts-characters-wrong-in-textarea-with-maxlength-attribute – defau1t Sep 19 '12 at 05:40

1 Answers1

1

It is because the EnterKey is considered to return two characters i.e "\r\n".

Thats the reason you are only able to press 10 times since the maxlength is 20.

Added: If you want use Jquery to resolve this :

var text = $('#textbox').val();

text = text.replace(/(\r\n|\n|\r)/g,"");    
djadmin
  • 1,742
  • 3
  • 19
  • 27