How to add counter function in textbox

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Counter.aspx.cs"
Inherits="Counter" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
<head runat="server">
<title>Untitled Page</title>

<script type="text/javascript">
function textCounter(field, countfield, maxlimit)

* The input parameters are: the field name;
* field that holds the number of characters remaining;
* the max. numb. of characters.
if (field.value.length > maxlimit) // if the current length is more than allowed
field.value =field.value.substring(0, maxlimit); // don't allow further input
countfield.value = maxlimit - field.value.length;



<form id="form1" runat="server">
<textarea name="message" cols="25" rows="4"
wrap="PHYSICAL" id="message" onkeydown="textCounter(this.form.message,

onkeyup="textCounter(this.form.message, this.form.remLen,50);
<input name="remLen" type="text" id="remLen" value="50" size="3"
maxlength="3" readonly />

No comments:

Post a Comment