Step 1: Put the following script in head section of your page (htm, asp, aspx, php....)
<script type="text/javascript">
var count = "250";
var len = "0";
function limiter() {
var tex = document.form1.txtmailmsg.value;
len = tex.length;
if (len > count) {
tex = tex.substring(0, count);
document.form1.txtmailmsg.value = tex;
document.getElementById("limit").innerHTML = len;
return false;
}
document.getElementById("limit").innerHTML = len;
}
</script>
Step 2: Create a textbox or input - type text or textarea or what ever you may call it.
Step 3: Call the function on "onKeyUp" event of the desired textbox.
<asp:textbox id="txtmailmsg" onkeyup="limiter()" runat="server" textmode="MultiLine"></asp:textbox>
Step 4: Put the following script at the desired place to display the counter
<script type="text/javascript">
document.write("<label id=limit>" + len + "</label>");
</script>
And you are done with the counter/limiter for your textbox.
Note: The reason to create label using JavaScript is to display the default number of character even for the first time as soon as page loads. If you don't need this, just put a simple label with id="limit"
Found it useful, please provide your comments...
1 comments:
This sort of machine had appeared in Australia from minimal of|no less than} 1994 with the Three Bags Full sport. With {this sort of|this kind of|this sort 1Xbet of} machine, the display adjustments to provide a unique sport during which an additional payout may be be} awarded. The first video slot machine was developed in 1976 in Kearny Mesa, California by the Las Vegas–based Fortune Coin Co.
Post a Comment