Linked Questions

2 votes
1 answer
1k views

Limiting characters in a textarea, how to account for carriage returns? [duplicate]

I would like to limit the user to entering 10 characters into a text area, and to notify the user when they approach the limit. I'm doing this by setting the maxLength attribute of the text area, and ...
ab11's user avatar
  • 20k
773 votes
26 answers
661k views

HTML-encoding lost when attribute read from input field

I’m using JavaScript to pull a value out from a hidden field and display it in a textbox. The value in the hidden field is encoded. For example, <input id='hiddenId' type='hidden' value='chalk &...
AJM's user avatar
  • 32.3k
120 votes
16 answers
252k views

How to impose maxlength on textArea in HTML using JavaScript

I would like to have some functionality by which if I write <textarea maxlength="50"></textarea> <textarea maxlength="150"></textarea> <textarea maxlength="250"></...
Rakesh Juyal's user avatar
  • 36.2k
55 votes
11 answers
158k views

Count textarea characters

I am developing a character count for my textarea on this website. Right now, it says NaN because it seems to not find the length of how many characters are in the field, which at the beginning is 0, ...
Ilan Biala's user avatar
  • 3,379
9 votes
3 answers
23k views

Text inputs with maxlength not validating with jQuery Validate

I'm stuck with a problem using jQuery Validate. The thing is I have a few textboxes with their maxlength attributes set. Although they are not required, they still fail to validate when either empty ...
rdumont's user avatar
  • 553
16 votes
1 answer
9k views

Why does Javascript only count carriage returns as one character when it is two?

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 ...
Naftali's user avatar
  • 146k
2 votes
2 answers
11k views

How to prevent input to a textarea after a certain character count is reached?

Using the below code, any input exceeding the specified maximum is removed. But this creates an effect where a character is typed and then immediately removed. I would prefer to simply prevent ...
ab11's user avatar
  • 20k
7 votes
1 answer
10k views

Different maxlength validation of textarea with newlines in Chrome and Firefox

The problem is that Firefox counts newline as "1"(\n) character while Chrome count them as "2"(\r\n) This is what I get in a textarea with maxlength=10: This are 10 charcters for Firefox 1234 5 6 7 ...
Carlos Escalera Alonso's user avatar
5 votes
3 answers
7k views

TextArea character counter using jQuery

I'm having trouble figuring out why my JavaScript is not working right. Its with j Query and its supposed to select all the text area tags and then for each text area count the number of characters ...
Sheldor's user avatar
  • 51
4 votes
4 answers
994 views

HTML - <textarea> tag difficulties

Problems: If textarea length exceeds its limit, and we give the input in the middle of the text than it start the truncate character from the end. But i don't want that textarea behavior. What I ...
Divyesh's user avatar
  • 438
3 votes
1 answer
11k views

Get the character count of a textarea including newlines

I tested this code in Chrome and there seems to be a bug involving the newlines. I am reaching the maxlength before I actually use all the characters. var ta = document.getElementById('myText'); ...
styfle's user avatar
  • 23.6k
4 votes
2 answers
3k views

Angular Text Area Counter Line Breaks SMS

I'm trying to make a character counter that mimics a phone for sms. I've got it counting characters, spaces, and line breaks, however my counters differ. With line breaks, it decrements by 1 in the ...
Anna Laura Davenport's user avatar
2 votes
1 answer
4k views

Return key in textarea counts as 2 characters for chrome

<html> <head> </head> <body> <textarea maxlength="10"></textarea> </body> </html> I am encountering an issue that counts return key as 2 characters....
Parisah's user avatar
  • 23
0 votes
3 answers
3k views

Jquery word counts when user type line break

I have a word counts create in jquery. http://jsfiddle.net/DqYsN/ However if user press 'Enter'(line break), it will cause 1 character left. ex.maxlength=10, if user type abcde, \n, abc total ...
user2178521's user avatar
1 vote
1 answer
3k views

count string length including 'invisible characters' like \r \n in javascript and php

I am trying to display a "x characters left" text next to a textarea, to see how much still can be written, with javascript / jquery: var area = 'textarea#zoomcomment'; var c = $(area).val().length; ...
haheute's user avatar
  • 2,179

15 30 50 per page