Counting Charcters follow up
The reason for counting characters is to limit the number of characters... so when the count reaches 400, I put up an alert explaining the user has reached the limit.
However, because I am using
My first thought was to trim the message. Didn't work.
My second thought was to kick the cursor out of the text box with blur.
But that doesnt seem to work. Any ideas?
BTW: the PHP does also trims the content - so the issue is just the UI and Javascript error, not the function.
Solution: Apparently there is a bug in FireFox 1.0.7 Mac that allows onkeypress to continue to work while the alert dialog is displayed. Disabling the text box before the alert, and then re-enabling it after the alert works. It also looks pretty slick. I'll probably do this anytime I have an alert regarding a form.
However, because I am using
onkeypress to count the characters, it still "works" when the Javascript error is up. That then results in the is error in FireFox:Error: uncaught exception: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIDOMTreeWalker.nextNode]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: chrome://global/content/bindings/button.x ml :: fireAccessKeyButton :: line 93" data: no]My first thought was to trim the message. Didn't work.
My second thought was to kick the cursor out of the text box with blur.
if(size > 400)
{
gID("MESSAGE").value = gID("MESSAGE").value.substring(0,399);
gID("MESSAGE").blur();
alert("During Beta Testing Messages are limited to 400 characters. Your message is "+size+" characters long.");
}But that doesnt seem to work. Any ideas?
BTW: the PHP does also trims the content - so the issue is just the UI and Javascript error, not the function.
Solution: Apparently there is a bug in FireFox 1.0.7 Mac that allows onkeypress to continue to work while the alert dialog is displayed. Disabling the text box before the alert, and then re-enabling it after the alert works. It also looks pretty slick. I'll probably do this anytime I have an alert regarding a form.
