Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limit length of a text area DTC

Status
Not open for further replies.

crystalized

Programmer
Jul 10, 2000
390
CA
Is there anyway to limit the length of a textarea DTC. I know that in HTML you can set a maxlength, however, I have not been able to find a way to set that with the textarea DTC. The max length field is disabled on the properties pages.

I need to limit the length otherwise I get an error when I try to add the record.


Any suggestions would be greatly appreciated.
 
Hi, Crystal
If memory is not an issue, you could change datatype for this field to text in SQL Server or to memo
in Access.
 
I actually want to limit the length of entry they are allowed in the database, so I don't think that option will work in this case, but thank you very much for the suggestion I will keep it in mind for other cases.

I am currently trying a validation that just checks the length of the value in the dtc and checking it against the size I will allow. Hopefully this will work. If it does I will post a note here on how I did it (in case anyone is faced with the same problem).

 
> validation that just checks the length of the value
That was the second suggestion that I was going to make.
Good luck.
 
Well the Microsoft documentation for <textarea> does not list any 'MAXLENGTH' attribute. Indeed my testing that attribute in IE5 on NT 4 confirms that it is not supported. Perhaps that is a feature of 'the other' browser? Does anyone know? I have seen several posts lately here on TT that site the 'maxlength' attribute for a <textarea> element.

Crystal,

It took me about 5 minutes to code the ability to have a 'MAXLENGTH' attribute in a DTC <textarea> element. Of course it appears to be completely useless (see above) so you shouldn't care. However if you do I will tell you how I did it.

-pete
 
Thanks palbano

I also abandoned the maxlength thing after about 5 minutes upon discovering how useless it was.

What i did do is this

someVar=len(textarea.value)

if someVar>myLimit then
let the user know

And it seems to be working just fine. Although I have to admit that I have not put in the exact amount of characters +1 to test, I just added a bunch beyond the allowed amount. But so far so good.
 
i wrote some code in the html/dhtml forum to test the length of a textarea's text. i just added an onkeypress event handler to the textarea, then if the length >= limit, return false. also, there is no maxlength attribute for a textarea
 
Dear Crystal,

This code works in IE5 on NT4, Win95, 98 and 2000.

Good luck
-pete

<script language=&quot;javascript&quot;>
<!--
function txKey(){

var oEle = window.event.srcElement;
if ( oEle.innerText.length > 15){
event.returnValue = false;
}else
return event.keyCode;
}
//-->
</script>
</HEAD>
<BODY>

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot; >
Note: <textarea id=&quot;txNote&quot; name=&quot;txNote&quot; cols=&quot;60&quot; rows=&quot;10&quot; onkeypress=&quot;return txKey()&quot;>
</textarea>
</form>
 
Thanks all, for the assistance. I really do appreciate the help from everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top