Feedback on: irt.org FAQ Knowledge Base Q1047
Length:
Just right
Comments:
The above code is fine, but it is possible to do this check while the user is actually entering code and not afterwards!! See this page for more details:
http://www.developer.com/experts/javascripts/answer189.html
Worth:
Very worth reading
Comments:
Thank you very much for providing this information!!
Prior to seeing this, I thought the only way to verify the length was after the user submitted the text. This would be very inconvenient and frustrating for them, losing all that they had typed.
As a newbie to this work, I really appreciate your kind and very worthwhile information!!!
Sheldon
Worth:
Worth reading
Length:
Too short
Technical:
Not technical enough
Comments:
The answer using onKeyUp is *BOGUS*! What happens if the user copy/pastes the text in using a mouse? Where does any onKeyUp even happen in that case?
This question misses the easiest answer of all that works on *ALL* browsers of which I am aware.
Just use a setTimeout to check the length of the text in the textarea every quarter second or so. Designer's choice as to whether it just chops the text to max size or pops up an alert.
Start the process at page load time and it works every time.
function checkTASize( )
{
var ta = document.FormName.TextAreaName;
if ( ta.value.length > 300 )
{
alert("Sorry...300 character limit");
ta.value = ta.value.substring(0,300);
}
setTimeout( "checkTASize()", 250 );
}
checkTASize( );