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 7182563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:47:47+00:00 2026-05-28T17:47:47+00:00

JavascriptScript: <script type=text/javascript> function limitText(limitField, limitCount, limitNum){ if (limitField.value.length > limitNum) limitField.value = limitField.value.substring(0,

  • 0

JavascriptScript:

   <script type="text/javascript">
        function limitText(limitField, limitCount, limitNum){
            if (limitField.value.length > limitNum)
                limitField.value = limitField.value.substring(0, limitNum);
            else{
                if (limitCount != null)
                    limitCount.value = limitNum - limitField.value.length;
            }
        }
    </script>

This works:

<form name="myForm">
    <textarea name="myTextArea" id="myTextArea" onKeyDown="limitText(this.form.myTextArea, this.form.remCount, 10);"></textarea>
    <label name="remCount" id="remCount"></label>
</form>

but this doesn’t:

<textarea name="myTextArea" id="myTextArea" onKeyDown="limitText(this.myTextArea, this.remCount, 10);"></textarea>
    <label name="remCount" id="remCount">Chars Left </label>

Using Chrome to debug it, if I don’t use the form method, then the limitField and limitCount are null, but in this.myTextArea is not. Is there anyway to use the function without enclosing the fields in a form? Thanks

  • 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-05-28T17:47:48+00:00Added an answer on May 28, 2026 at 5:47 pm

    Just pass this by itself. It’ll be the element itself. To find the “count” label, you can always use document.getElementById() to find it.

    Also, though this isn’t part of your question: be aware that browsers report different values for the length of a textarea when the value includes hard line breaks; that is, line breaks that are present due to the user typing the “Enter” key. Some browsers treat line breaks as being worth 2 characters, because in fact they are two characters long when a <textarea> is posted back to the server from a form. However, some browsers only report a line break as being 1 character long, even though they follow the relevant spec and send the <textarea> value back with 2-character line breaks.

    Modern browsers support the maxlength attribute on <textarea> elements, but for the reasons outlined above it doesn’t work properly in Chrome and Firefox (though I think a fix is working its way through WebKit).

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

Sidebar

Related Questions

I have a JavaScript script: $(#feedbacksubmit).click(function() { if($(#frmfeedback).valid()) { var tname = $(#name).val(); var
I have a function in my Javascript script that needs to talk with the
I'm searching for a jQuery or simple, old-school JavaScript script which makes text input
I currently have a preloading image javascript script: function MM_preloadImages() { var d =
When I run javascript script file in windows command line environment, and there is
How do I pass have a Javascript script request a PHP page and pass
I'm looking for a customizable JavaScript script which dynamically highlights code in a block
I am trying to debug a JavaScript script that gets read in a Firefox
Tried to make a little old school ajax (iframe-javascript) script. A bit of mootools
Is there a Javascript script to change the time and date of blogs automaticly

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.