Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7741637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:04:34+00:00 2026-06-01T09:04:34+00:00

This is an offshoot of this question: Chrome counts characters wrong in textarea with

  • 0

This is an offshoot of this question: Chrome counts characters wrong in textarea with maxlength attribute


In that question it was found that Javascript counts carriage returns are one character when in fact it is two (\r\n), why is that?

Test Fiddle: http://jsfiddle.net/maniator/E527z/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:04:35+00:00Added an answer on June 1, 2026 at 9:04 am

    For reasons unknown, jQuery always converts all newlines in the value of a <textarea> to a single character. That is, if the browser gives it \r\n for a newline, jQuery makes sure it’s just \n in the return value of .val(). (Actually the reason probably isn’t “unknown”; it’s probably to normalize the results across browsers, because IE reports newlines as being 2 characters long.)

    Chrome and Firefox both count the length of <textarea> tags the same way for the purposes of “maxlength”.

    However, the HTTP spec insists that newlines be represented as \r\n. Thus, jQuery, webkit, and Firefox all get this wrong. When the field is posted, webkit and Firefox correctly add the newlines!

    The upshot is that “maxlength” on <textarea> tags is pretty much useless if your server-side code really has a fixed maximum size for a field value.

    Edit This is still an issue in 2015 – at least on Chrome 45.0.2454 and IE 11.0.9600.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an offshoot question that's related to another I asked here . I'm
This is an offshoot of this question . How do I use a Login
This is an offshoot to my other question . Is there something special I
This is an offshoot of a previous question which started to snowball. If I
This is an offshoot from a previous question, is this bad practice (using the
this is my code that I write it but I want to use LINQ
This is probably a stupid question, but how much of a security risk is
This is a complex question, because there are a lot of moving parts. My
This is an offshoot of these two questions: 1 , 2 . I'd like
This is my first time creating a PHP form that will run a MySQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.