Articles, Tips & Tricks, Usefull Softwares

Menghitung Sisa Huruf / Karakter pada Textarea

Ingin mengetahui berapa huruf lagi yang dapat Anda ketikkan di Textarea? maka gunakanlah script dibawah ini.

<form name=”myForm”
<b>One Function to Count and Limit Multiple Form Text Areas</b><br>
<textarea name=”message1″ wrap=”physical” cols=”28″ rows=”5″
<input readonly type=”text” name=”remLen1″ size=”3″ maxlength=”3″ value=”125″>
characters left
<textarea name=”message2″ wrap=”physical” cols=”28″ rows=”5″
<input readonly type=”text” name=”remLen2″ size=”3″ maxlength=”3″ value=”125″>
characters left
<input type=”Submit” name=”Submit” value=”Submit”>

Dan letakkan script di bawah ini di bagian <HEAD>….</HEAD> website Anda.

<!– Dynamic Version by: Nannette Thacker –>
<!– –>
<!– Original by :  Ronnie T. Moore –>
<!– Web Site:  The JavaScript Source –>
<!– Use one function for multiple text areas on a page –>
<!– Limit the number of characters per textarea –>
<!– Begin
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long…trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update ‘characters left’ counter
cntfield.value = maxlimit – field.value.length;
//  End –>

Ok, silahkan mencoba..

December 15, 2008 - Posted by | Programming | , ,

No comments yet.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: