|
|
 |
RE: FN-FORUM: Javascript error
date posted 21st September 2007 12:05
Hi,
>I assume there is not a
>
>before this? That would be the error.
The form does have the before it.
>How about this code instead?
>
>function LimitTextArea(e,limit)
>{
> var div =document.createElement('div');
> div.id=id+'_charsrem';
> div.className='charsrem';
> e.parentNode.appendChild(div);
> div.style.width=(e.clientWidth-5)+'px';
> e.onchange=function() {
> if(e.value.length>limit)
> {
> var sub=e.value;
> sub=sub.substring(0,limit);
> e.value=sub;
> }
> div.innerHTML='You may enter a further
'+(limit->e.value.length)+'
>characters.';
> }
> e.onkeyup=e.onchange;
> e.onchange();
>}
>
>You will want some css to make the counter look nice, like this:
>
>div.charsrem {
> border-left:1px solid #aaa;
> border-right:1px solid #aaa;
> border-bottom:1px solid #aaa;
> font-size:11px;
> background-color:#efefef;
> padding: 3px;
> font-family:Verdana,Arial;
>}
>
>And the text area code would be:
>
>onload="LimitTextArea(this,1000)" >
>
>I personally think my code is nicer, since it doesn't display a
>disfunctional countdown if javascript is turned off. Of course you
would
>want to check the text posted to the server in case Javascript is
turned
>off.
I don't mind what code I use.
How does yours work? Does it display a counter? I just tried it and
put tones of characters in the textbox but nothing happened.
|
 |
|