Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
3.80/5 (3 votes)
See more:
I Have a Text Box with Multiline Text Mode and a Label ,
What i Have to do is my Text Box should allow <=150 characters and while typing, my label should show the number of remaining characters left to enter in Text Box out of total 150 characters .
Posted

 
Share this answer
 
 
Share this answer
 
C#
function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, 160);
        field.blur();
        field.focus();
        return false;
    } else {
        countfield.value = maxlimit - field.value.length;
    }
}
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900