473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

maxlength on multiline textbox

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 textbox not support maxlength?
How can I make the work?

TIA
Nov 18 '05 #1
4 8144
No the max length doesn't work as the html tag rendered is a textarea tag,
which has no MaxLength property.

You will need to use a Validator control to ensure the length doesn't exceed
the MaxLength. You could use a RegExValidator or derive your own from
CustomValidator.

HTH,

bill
"hardcoded" <mt*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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 textbox not support maxlength?
How can I make the work?

TIA

Nov 18 '05 #2
Just as I suspected. Thanks!

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:eF**************@TK2MSFTNGP10.phx.gbl...
No the max length doesn't work as the html tag rendered is a textarea tag,
which has no MaxLength property.

You will need to use a Validator control to ensure the length doesn't exceed the MaxLength. You could use a RegExValidator or derive your own from
CustomValidator.

HTH,

bill
"hardcoded" <mt*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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 textbox not support maxlength?
How can I make the work?

TIA


Nov 18 '05 #3
WJ

"hardcoded" <mt*******@hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...
Just as I suspected. Thanks!


Not much you can do on any web-based application. Price to pay for ! :)

John
Nov 18 '05 #4
try the this

<HTML>
<HEAD>
<SCRIPT>
function fun_pTextarea_MaxLen(prm_oTextarea_Obj)
{ var var_sKey_Code, var_aKey_Special, var_bResult,
var_oTextarea_TxtRng;

var_oTextarea_TxtRng = prm_oTextarea_Obj.createTextRange();
var_aKey_Special = [8,17,18,27,33,34,35,36,37,38,39,40,45,46,114];
var_bResult = true;
var_sKey_Code = event.keyCode;
if (var_sKey_Code == 86)
{ if (event.ctrlKey) var_bResult =
fun_mTextarea_Paste(prm_oTextarea_Obj); }

if(prm_oTextarea_Obj.value.length >= prm_oTextarea_Obj.maxLen)
{ var_bResult = false;

if (var_oTextarea_TxtRng.queryCommandState('OverWrite ') &&
(prm_oTextarea_Obj.value.length == prm_oTextarea_Obj.maxLen))
{ var_bResult = true; }
else
{
for (i=0; i<var_aKey_Special.length; i++)
{ if (var_sKey_Code == var_aKey_Special[i]) {var_bResult = true;
break;} }
}
}

return var_bResult;
}

function fun_mTextarea_Paste(prm_oTextarea_Obj)
{ var var_sClipboard_Text;
var_sClipboard_Text = window.clipboardData.getData("Text");
prm_oTextarea_Obj.TxtRng =
document.selection.createRange().duplicate();

if (prm_oTextarea_Obj.TxtRng && prm_oTextarea_Obj.createTextRange)
{ prm_oTextarea_Obj.TxtRng.text =
prm_oTextarea_Obj.TxtRng.text.charAt(prm_oTextarea _Obj.TxtRng.text.length
- 1) == ' ' ? var_sClipboard_Text + ' ' : var_sClipboard_Text;
}
else
{ prm_oTextarea_Obj.TxtRng.text = var_sClipboard_Text;}

prm_oTextarea_Obj.value = prm_oTextarea_Obj.value.substring(0,
prm_oTextarea_Obj.maxLen);
return false;
}

</SCRIPT>
</HEAD>
<BODY>
<textarea maxLen=10 onkeydown="return
fun_pTextarea_MaxLen(this);"></textarea>
</BODY>
</HTML>

(phoenix398017)
"hardcoded" <mt*******@hotmail.com> wrote in message news:<#q**************@TK2MSFTNGP11.phx.gbl>...
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 textbox not support maxlength?
How can I make the work?

TIA

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mg | last post by:
I have a MultiLine TextBox (WebForm - C#) with the MaxLength property = 1000 but am able to type in an unlimited number of characters. Is there a way to limit the number of characters that can be...
3
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...
2
by: Craig G | last post by:
how do you do it? i understand the maxlength property has no effect but is there a way around it?
10
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" />
3
by: h | last post by:
Hi, I have set my textbox's maxlength property to 1 , however it allow more than one word. Is there any settings that I am missing ? Thanks in advance Hardik Shah
5
by: Not Me | last post by:
Hi there, There are hundreds of messages with different solutions on how to limit the number of characters for a text box in ASP.net, none of which I can get to work!! I do lie, because using...
2
by: Nathan Sokalski | last post by:
As we probably know, the MaxLength property of the TextBox control only works when the TextMode property is SingleLine or Password. I want to limit the number of characters a user can enter into a...
6
Coldfire
by: Coldfire | last post by:
I am having problems with Maxlength of Multiline "Textbox". I have browsed alot to find the solution. Tons of javascripts have been found but they all deal with <asp:textarea >............. and...
3
by: gomzi | last post by:
hi, I am trying to set the maxlength property of a multiline textbox without much success. Could anyone tell me as to how it could be done ? thanks, gomzi.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.