jo
|
Posted: 01/17/2002, 11:28 AM |
|
I have a field (event_description) that is a textarea -- it is set for row="3"
cols="60" -- I was hoping that the user could only enter up to 3 rows -- but when the description is longer the user can continue to enter data -- I'm using SQL server and the field is varchar (255) so I don't want the user to enter more than 255 characters -- What are my options ?? I though I could limit the textarea with rows and cols but that doesn't seem to be the case -- Any suggestions ?? Thanks jo
|
|
|
Nicole
|
Posted: 01/18/2002, 1:17 AM |
|
Jo,
textarea let you enter unlimited number of character and it cannot be limited as e.g. textbox. The workaround is to use javascript that will cut extra characters. E.g.:
<SCRIPT Language="JavaScript">
document.FormName.FieldName.onkeydown=myfunc;
function myfunc() {
var tmp = 0;
var tmp1 = 0;
tmp = document.FormName.FieldName.value;
tmp1 = tmp.length;
if (tmp1 >= 255)
document.FormName.FieldName.value = document.FormName.FieldName.substr(0, 255);
}
</SCRIPT>
As usual javascript code is to be added to footer section of the form.
|
|
|
aung
|
Posted: 01/18/2002, 2:15 AM |
|
there's no textarea limit. one possible solution might be to use javascript to ensure the user enters less than 255 characters. or maybe u can do something with sql to allow more than 255. ( but i have no idea about sql. )
|
|
|
Tom
|
Posted: 01/31/2002, 12:10 PM |
|
I'm just learn js but I think there is an error in the one statement that Nicole provided ...
was
document.FormName.FieldName.value = document.FormName.FieldName.substr(0, 255);
should be
document.FormName.FieldName.value = document.FormName.FieldName.value.substr(0, 255);
Hope that helps
|
|
|