View Full Version : String length limitation in Javascript?
biznusman
10-11-2002, 09:16 PM
Is there a string length limitation in Javascript? I have a function that checks the length of a textarea and displays an alert if the length goes over a set amount. When the length of the string exceeds about 1700 chars, the javascript ceases to function. Any insight would be appreciated.
beetle
10-11-2002, 09:35 PM
I'm sure there's a practical limitation, but I don't know what.
Let's see your code, maybe it can be finessed...
whammy
10-11-2002, 10:05 PM
1700 characters shouldn't make a difference... see:
http://www.solidscripts.com/solidscripts_new/displayscript.asp?sid=1
Alex Vincent
10-12-2002, 02:26 AM
What browsers? If it's a Netscape / Mozilla browser, maybe I can find a bug on it. (I've vaguely heard of a problem slightly similar...)
whammy
10-12-2002, 02:50 AM
There are a lot of bugs when you take all browsers into consideration... however as far as I know (and I REALLY want to know if it doesn't work in one), the above script should work in ANY javascript enabled browser (4.x + ... whatever "brand") I tried in that case (a long time ago) to take a simple approach to cross-browser compatibility... and as far as I can tell, it works!
chrismiceli
10-12-2002, 02:57 AM
why couldn't you just do this??
if (document.formname.textfieldname.length > 150) {
alert("to many characters")
}
whammy
10-12-2002, 02:59 AM
You can... I just tried to get a little more elegant with the script I posted.
Basically, in IE whatever, (and some versions of Netscape), it won't let you type once you've reached the character limit.
Although in those browsers, you can still PASTE beyond that.
Otherwise, that's EXACTLY what my script does, besides updating the status bar with the current number of characters. But it's a lot nicer in IE since it just keeps people from typing any further. :D
I like simplicity. But, I did have to modify it to be XHTML 1.1 compliant. ;)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.