|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Stumped by textarea limit
I have a form which has several small inputs but also one large input area. Anticipate the entrant will copy and paste 1000-3000 characters. Testing has shown that the limit on the input seems to be about 1036 characters. My reading of the html rules and searches in different forums seem to indicate that no character limit exists.
1. I have tried using both textarea and input type=text and find I can't go past this approx 1000 character barrier. 2. I have tried putting in a maxlength=3000 statement to no avail. The code snippet is: <td>Today's Message:</td> <td> </td> <td><input textarea name="themessage" cols="60" rows="60"></textarea></td> My apologies if this is something easy. I have tried to do due dilligence to reading the manuals and such. |
|
#2
|
|||
|
|||
|
Are you sending the form via 'get'? That will impose a character limit, since you're sending your info through the url.
|
|
#3
|
|||
|
|||
|
Quote:
Thanks for that tip! I didn't know the answer to that and searched my html document for GET and came up with nothing. I googled forms and get and found http://www.htmlhelp.com/reference/html40/forms/form.html which has a section indicating that GET is the default method but does have a limit on characters. That page recommends that POST method be used for the action since my submission has greater than 100 characters. I don't know that I have ever used POST as my method. May require me to change the way I am coding my PHP/MYSQL web pages. The same page that presents the Web Form is also putting the submitted data into the MYSQL database using PHP. But Changing the way I code is ok. Better to do it right! Thanks so much for pointing me in the right direction. I really appreciate that. I have learned so much from devshed.com over the past 2 years and have encouraged 50-100 people to go to your site to educate themselves using the tutorials. This is the best of the web! |
|
#4
|
||||
|
||||
|
First point, your code snippet is a little incorrect...
Try: <textarea name="themessage" cols="60" rows="60"></textarea> [you had the word input in there] The Textarea element currently does not support the maxlength attribute... There is an Internet Explorer proprietary solution, but it only works in IE... This involves creating an HTC file and setting the style "BEHAVIOR" to direct to that HTC file... I do not advise this solution, as it is an IE only solution... The HTC File (titled maxlength.htc) Code:
<PUBLIC:COMPONENT id="bhvMaxlength" urn="maf:Maxlength">
<PUBLIC:PROPERTY name="maxLength" />
<PUBLIC:ATTACH event="onkeypress" handler="doKeypress" />
<PUBLIC:ATTACH event="onbeforepaste" handler="doBeforePaste" />
<PUBLIC:ATTACH event="onpaste" handler="doPaste" />
<SCRIPT language="JScript">
// Keep user from entering more than maxLength characters
function doKeypress(){
if(maxLength && value.length > maxLength-1){
event.returnValue = false;
maxLength = parseInt(maxLength);
}
}
// Cancel default behavior
function doBeforePaste(){
if(maxLength)
event.returnValue = false;
}
// Cancel default behavior and create a new paste routine
function doPaste(){
if(maxLength){
event.returnValue = false;
maxLength = parseInt(maxLength);
var oTR = element.document.selection.createRange();
var iInsertLength = maxLength - value.length + oTR.text.length;
var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
oTR.text = sData;
}
}
</SCRIPT>
</PUBLIC:COMPONENT>
Your HTML Code:
<html>
<head>
<style>
TEXTAREA { behavior: url(maxlength.htc);}
</style>
</head>
<body>
<form>
<textarea name="themessage" cols="60" rows="60" maxlength="100"></textarea>
</form>
</body>
</html>
Repeat: I do not advise this solution, as it is an IE only solution... Instead I suggest pestering the W3C to consider the maxlength property in the next XHTML spec revision In the meantime, always do server side validation... also code a javascript validation |
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Web Development > Stumped by textarea limit |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|