Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8639097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:54:46+00:00 2026-06-12T10:54:46+00:00

This is my code: function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) {

  • 0

This is my code:

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;
    }
}

How can I display how many characters are remaining from a certain text box with a limit of 160?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:54:48+00:00Added an answer on June 12, 2026 at 10:54 am

    Dynamic HTML element functionThe code in here with a little bit of modification and simplification:

    <input disabled  maxlength="3" size="3" value="10" id="counter">
    <textarea onkeyup="textCounter(this,'counter',10);" id="message">
    </textarea>
    <script>
    function textCounter(field,field2,maxlimit)
    {
     var countfield = document.getElementById(field2);
     if ( field.value.length > maxlimit ) {
      field.value = field.value.substring( 0, maxlimit );
      return false;
     } else {
      countfield.value = maxlimit - field.value.length;
     }
    }
    </script>
    

    Hope this helps!

    tip:

    When merging the codes with your page, make sure the HTML elements(textarea, input) are loaded first before the scripts (Javascript functions)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript function as follows function textCounter(field, rem, maxlimit) { if (field.value.length
i have this code $(function() { $('#ans_vote a span').click(function(){alert('working');return false;});}); and this html <div
Given this code: function Test(){ var $D = Date.prototype; $D.addDays=function(value){this.setDate(this.getDate()+value);return this;}; $D.clone = function()
I got this code: function zeroPad(num, places) { var zero = places - num.toString().length
This code does not function as expected: // $field contains the name of a
For instance this code: function stuff() { this.onlyMethod = function () { return something;
I'm fetching an XML file using this code: function getMaps(){ toLoad = loadMaps.length; for
I have this code function test(){}; test.prototype.testMethod = function(){return 1;} var t = new
Consider this code: function klass( z ) { this.a = z; return this; }
So i have this code: function myOnFocus(){ $('tr').css(background-color,white); $(this).parent().parent().css(background-color,blue); } $(.priority).focus(myOnFocus()); How can i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.