473,507 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Maxlength Issue

2 New Member
Hi all,

I have a situation here. The below snippet is used to get a textarea, but I have not been able to figure out as to how I can limit the number of character the user enters.... (say limit to 20). I am looking for a maxlength type of function or something which would implement on same lines.

Expand|Select|Wrap|Line Numbers
  1. <OBJECT style="z-index:1;" classid="clsid:2D360201-FFF5-11d1-8D03-00A0C959BC0A" width="100%" height="100%" id="MSHTMLObject<%=editCounter%>" %>">
  2. <PARAM NAME=ScrollbarAppearance VALUE=0>
  3. </OBJECT>
Any suggestions would be most welcome.
Best regards,
Srinivasa
Dec 8 '07 #1
3 1137
gits
5,390 Recognized Expert Moderator Expert
hi ...

you may use something like in the following example:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.  
  4.     <script type="text/javascript">
  5.         function chk_txt(node, max_val) {
  6.             var txt = node.value;
  7.             var l   = txt.length;
  8.  
  9.             if (l > max_val) {
  10.                 node.value = txt.match(/.{20}/);
  11.                 l = node.value.length;
  12.             }
  13.  
  14.             var no_dspl = document.getElementById('txt_length');
  15.             no_dspl.innerHTML = l;
  16.         }
  17.     </script>
  18.  
  19.     </head>
  20.     <body>
  21.         <textarea id="my_txt" onkeyup="chk_txt(this, 20);" rows="5"></textarea>
  22.         <br/>
  23.         current no. of chars &nbsp;
  24.         <span id="txt_length" style="color: red;">0</span>
  25.     </body>
  26. </html>
  27.  
it uses a regular html-textarea instead of an embedded object ... why do you use that? may be the object itself has some properties you may use to limit the maxlength but in case you could use a normal html-textarea, you may use the sample above ...

kind regards
Dec 9 '07 #2
bssrinivasa
2 New Member
Hi Gits,

Your code looks good, however I would have to use the embedded object itself.
In this regard, could you provide me some solution or guide me to any write ups on the object so that I can check if there are any intrinsic properties i can make use of?

Best regards and thanks,
Srinivasa
Dec 10 '07 #3
gits
5,390 Recognized Expert Moderator Expert
hi ...

it seems its a MS dhtml edititing component ... start to search for its use here

kind regards
Dec 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
11428
by: Lovely Dola | last post by:
I have set the MaxLength property of a textbox in a form to 5 at design time. When I change the MaxLength back to 0 during run-time under some condition (for example, after clicking a command...
5
7416
by: Edward Mitchell | last post by:
I have a database with text string fields defined by varchar(nnn). When I request from the user the text from a textbox, I'd like to set the maximum number of characters in the textbox to the...
7
2602
by: ray | last post by:
My xsd has the following element: <xs:element name="Company" minOccurs="0"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1" /> <xs:maxLength value="5" />...
1
240
by: Darren Clark | last post by:
Anyone have a solution for being able to set a max char limit for a textarea?
4
8151
by: hardcoded | last post by:
I have a textbox with TextMode set to MultiLine. I also have the MaxLength set to 255. This maxlength value seems to get ignored as the user can enter unlimited characters. Does the multiline...
3
5040
by: RSB | last post by:
Hi Everyone, I have this TextBox with the TextMode="MultiLine". so now it does not validate the text in the TextBox for the MaxLength SO i have decided to execute a CustomValidator for this...
10
3645
by: danthman | last post by:
I have a TextBox set up as follows: <asp:TextBox ID="SubjectTextBox" TextMode="MultiLine" MaxLength="100" Columns="50" Rows="2" Wrap="true" runat="server" />
1
1913
by: Mel | last post by:
Anyone know how I would retrieve the MaxLength property of a column in my Access Database table? I know how to retrieve table data, for example the "Quote #" field in my example code below, but I...
3
3029
by: engineer | last post by:
Hi, I'm trying to control the maxlength property of a textbox in javascript. But it's not going into effect.This is my code HTML <input type=text id="txt_search_string" class=formtext...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.