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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:37:18+00:00 2026-05-25T01:37:18+00:00

I need to set the maximum character input for users simililar to how stackoverflow.com

  • 0

I need to set the maximum character input for users simililar to how stackoverflow.com works. I plan on using javascript to provide feedback to the user and count the characters. Only submissions that don’t exceed the maximum character count are allowed. I don’t plan on using the xhtml input properties to limit this amount as I’ll allow overage on characters as long as they are not submitted. On the backend I’ll just set the varchar field in mysql to charmax.

Question is, how do I count character inputs, do I base it off of onkeydown() or onkeyup(). I’m not too sure why there are two functions, because a key that goes down must come up, so which one should I use to do the counting?

  • 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-25T01:37:19+00:00Added an answer on May 25, 2026 at 1:37 am

    HTML:

    <input type='text' id='text'/>
    

    JS:

    function textLength(value){
       var maxLength = 144;
       if(value.length > maxLength) return false;
       return true;
    }
    
    document.getElementById('text').onkeyup = function(){
         if(!textLength(this.value)) alert('text is too long!');
    }
    

    Here is a fiddle demo: http://jsfiddle.net/maniator/L2LRK/

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

Sidebar

Related Questions

I am using Zend_File_Transfer_Adapter_Http for uploading Images. I need to set maximum size of
I'm using Apache.NMS 1.4. I need to be able to programmatically set the maximum
I need to set a maximum widht to a label tag and avoid the
I need to return my result set in XML and this works fine, but
I need to set a maximum limit of rows in my MySQL table. Documentation
I had set minRequiredPasswordLength,minRequiredNonalphanumericCharacters in membership section of web.config file. but i need maximum
I need to set maximum height and width of a image in <img> tag.
I need to set the width of <li> based on the maximum string length
I'm designin a pub/sub architecture using ZMQ. I need maximum reliability and scalability and
Need set zoom for camera preview...

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.