I have a javascript function as follows
function textCounter(field, rem, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
rem.value = maxlimit - field.value.length;
}
I am trying to call it from code behind by passing clien ID’s
ClientScript.RegisterStartupScript(this.GetType(), "myScript", "textCounter('" + txtRemark.ClientID + "','" + txtRemarksRem.ClientID + "', '2000')", true);
But I am unable to get the values of the associated fields.
I am getting null value for “field.value.length”
Let me know the issue.
You are passing only client Ids for the controls, but not the control, you should first get those control to work.
for that you should change your code as