简体   繁体   中英

Issue with text-area in chrome browser

I have textarea with maxlength attribute ie 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.

It is because the EnterKey is considered to return two characters ie "\\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,"");    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM