@nahummadrid – nice solution. It’s concise, and responsive (VERY important). Every other solution I’ve tested slows down the text input to a crawl, which isn’t acceptable for a public site and will really annoy anyone who types with all their fingers. I haven’t encountered the issue to which you alluded re. users breaking the limit with copy/paste. It’s working flawlessly. Thanks a bunch for it.
@justbishop – yes, the code display has been mangled by wp texturise, and contains a cpl small errors. Here it is clean:
<script type="text/javascript">
//<![CDATA[
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}
//]]>
</script>
<textarea id="whats-new" cols="50" rows="10" name="limitedtextarea" onkeydown= "limitText(this.form.limitedtextarea,this.form.countdown,148);" onkeyup="limitText(this.form.limitedtextarea,this.form.countdown,148);" /><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ) ?> <?php endif; ?></textarea>
<input readonly="readonly" type="text" name="countdown" size="3" value="148" id="whateveryouwant" />
Incidentally, I think it’s best to place the script itself in entry.php, not post-form.php (assuming you’re also setting a character limit on replies). The reason for this is that it should only be loaded once, and if you place it in post-form.php it won’t be available on an individual activity page (ie. the page you get when you click the “View” link), but if you place it in entry.php it will be loaded when viewing the activity stream, and also when viewig the individual activity.