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

  • SEARCH
  • Home
  • 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 243173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:53:57+00:00 2026-05-11T20:53:57+00:00

I have a textarea in C#, please see below code: <asp:Label ID=lblQuestions runat=server CssClass=addinfo>

  • 0

I have a textarea in C#, please see below code:

<asp:Label ID="lblQuestions" runat="server" CssClass="addinfo">
                    Question & Comments</asp:Label>
<asp:TextBox ID="txtQuestions" Rows="5" Columns="5" TextMode="MultiLine" runat="server" MaxLength="250"></asp:TextBox>

Now I want that textarea should not accept more than 250 characters, whatever user do COPY & PASTE, by WRITING and DRAG & DROP etc, if user try to copy or drag & drop more than 250 character the first 250 characters should be copied in textarea. I know that there no MAXLENGTH attribute in TEXTAREA. If it is not possible with .NET the solution with javascript or Jquery will work.

Please help

  • 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-11T20:53:57+00:00Added an answer on May 11, 2026 at 8:53 pm

    You have to wire functions for the events

    onpaste, onkeyup and onfocus of the area for which you want to do this action.

    For an asp textbox I think you have to consider only OnTextChanged event.

    For textarea

    <INPUT id="counterMessage" readOnly size="3" value="250" name="counterMessage">                                                                                                     
    <TEXTAREA onpaste="PasteCounter(this.form.txtAreaMessage,this.form.counterMessage,250);"
                                                                                                                                id="txtAreaMessage" onkeyup="textCounter(this.form.txtAreaMessage,this.form.counterMessage,250);"
                                                                                                                                style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; OVERFLOW: hidden; BORDER-LEFT: 0px; WIDTH: 99%; BORDER-BOTTOM: 0px; HEIGHT: 95px; TEXT-ALIGN: justify"
                                                                                                                                onfocus="textCounter(this.form.txtAreaMessage,this.form.counterMessage,250);" name="txtAreaMessage"
                                                                                                                                rows="3" runat="server"></TEXTAREA>
    
    
    function PasteCounter(field, countfield, maxlimit)
            {
                var len;
                var txt = clipboardData.getData("Text");
                txt = field.value + txt
                len = parseInt(txt.length);
                if ( len >  maxlimit )
                {
                    event.returnValue=false;
                    txt = txt.substring(0, maxlimit);       
                    field.value = txt;                  
                    alert("Only " + maxlimit + " characters are allowed");
                }
                countfield.value = maxlimit - txt.length;
            }    
            function textCounter(field, countfield, maxlimit)
            {
                if (field.value.length > maxlimit )
                {      
                    field.value = field.value.substring(0, maxlimit );
                    alert("Only " + maxlimit + " characters are allowed");
                }
                countfield.value = maxlimit - field.value.length;
            }
    

    The countfield textbox is for showing remaining characters.

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

Sidebar

Related Questions

Please see this jsFiddle: https://jsfiddle.net/Wmq6f/ I have a textarea that has a background image,
I have the following HTML code: <div id=summary_form> <textarea class=summary>Please fill in</textarea><br/> <textarea class=summary>Please
I have following html code with 5 textarea's and 5 buttons below them. What
Please check out my code here http://jsfiddle.net/bYDPr/20/ So I have some HTML textarea elements
I have below code in html <div id=divTest> Hello <input type=text id=txtID/> <input type=text
Please take a look at this fiddle: http://jsfiddle.net/hughbe/QYGcq/ As you can see, the label
I have: <textarea id='txtSomeId'><p><span>. </span><span>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</span><span>Bullet one </span> </p> </textarea> When I use jQuery's $(#txtSomeId).val()
I have used a label box to render a please wait message when the
I have textarea in my site(link shortening site) i want to user enter some
I have a textarea with many lines of input, and a JavaScript event fires

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.