Display a Counter For a Textarea

Display a Counter For a Textarea

javascript:

function VerifyMsg(f_ld,c_nt,cnt_fld) {

var len = f_ld.value.length
var cl

if ((len == 1) && (f_ld.value.substring(0, 1) == " ")) {
f_ld.value = ""
len = 0
}
if (len > (c_nt-10)) {
f_ld.value = f_ld.value.substring(0, c_nt)
cl = 0
}
else {
cl = c_nt – len
}
eval(cnt_fld).value = cl
}

HTML

<FORM ACTION="pageSample.php" METHOD="POST" name="Sponsored" onSubmit="return SpOrdrVal();"><textarea rows="4" cols="40" name="SiteDesc" wrap="on" onkeydown="VerifyMsg(this,’500′,’document.Sponsored.Counter’)" onfocus="VerifyMsg(this,’500′,’document.Sponsored.Counter’)" ></textarea>
<br /><span class="InfoMsgs">max 500 chars; </span><span class="CounterText">characters remaining : </span><input type="text" value="500" disabled="disabled" size="4" name="Counter" id="Counter" class="CounterText" /></form>

Advertisements

~ by UTS on May 4, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: