Mobile Textarea: How Many Characters Left

javascript textarea characters

We’re up to Version 3.0 of the WordPress Mobile Plugin utilizing Connective Mobile’s API and Text Club feature.

Connective Mobile has a 150 Character limit for your Mobile Marketing message that you want to broadcast to your subscribers. Rather than having someone wonder how many characters they have left, I modified Geeky Grrl’s little in-line Javascript method to display the number of characters left:

<textarea style="margin-left: 50px; margin-top: 4px" rows="2" cols="60" name="wpcm_message" id="wpcm_message" onKeyUp="i=150;val=this.value; if(val.length>i) { this.value = val.substring(0,i); wpcm_message.focus() } document.getElementById('textcount').innerHTML=i-parseInt(this.value.length);"></textarea><br /><br /><small><span id="textcount" style="margin-left:50px">150</span> characters left.</small>

The way it works is by changing the value for i in the script for the number of characters you wish to limit the text area by. As you type (onKeyUp event in Javascript), the script changes the value of the number of characters left within the HTML span textcount. It’s a quick and dirty script, but works great!

characters left javascript

About the WordPress Mobile Alert Plugin

We’ve got some interest in some sites that are used to alert folks – like weather blogs, security blogs, neighborhood watch blogs, real estate blogs, national relief blogs, and e-commerce blogs. Aside from an internal mechanism to alert everyone, the plugin can be used to automatically alert subscribers whenever there’s a new post.

Imagine how useful this would be for the Red Cross or other organizations that are now using WordPress. If they post about resources needed in certain regions of a hurricane, for instance, any subscriber can be alerted and go read the post for additional information!

If you’re a blogger in the United States and would like to try to put this plugin to work, let Connective Mobile know through their site. We’re looking for some beta testers!

One comment

  1. 1

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.