By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,959 Members | 1,160 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,959 IT Pros & Developers. It's quick & easy.

maxlength on multiline textbox

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.