| Author |
Message |
drums
Toilet Drinker


Joined: 19 Jun 2003 Posts: 234
Location: Portland, OR
|
Posted:
Tue Dec 15, 2009 8:52 pm Post subject: Anyone know why maxlength is invalid? |
|
I get this error on a form mail.
Quote:Attribute "MAXLENGTH" is not a valid attribute. Did you mean "maxlength"?
<br><textarea name="Message" maxlength="1000" class="text blkbars" cols="30" row
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.
I have it in lowercase and here's my doctype stuff (not sure what it's called). There are a total of 8 of these email (form mail) pop-up pages:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
And the HTML
<textarea name="Message" maxlength="1000" class="text blkbars" cols="30" rows="5">
Thanks in advance for your time and hopefully help! |
_________________
|
|
|
|
|
CMTG
Leg Humper


Joined: 23 Feb 2002 Posts: 5449
Location: /var/log/cabin
|
Posted:
Wed Dec 16, 2009 4:04 am Post subject: |
|
It's because "maxlength" is not a valid attribute for the <textarea/> element, just like the error message says.
See: http://www.w3schools.com/tags/tag_textarea.asp |
_________________ Pie. I wish I could
constrain my hungry greed but...
Sadly, defeated.
Charlene's Law: There's no such thing as can't.
Charlene's Corollary: Unless it's followed by be arsed.
I write more quotes than a fucking big book of quotes. - Scroobius Pip
http://fedoraproject.org/get-fedora
|
|
|
|
|
gregw
Tail-Wagger

Joined: 25 May 2003 Posts: 2999
Location: About 2000 miles south of where I want to be.
|
Posted:
Wed Dec 16, 2009 7:49 am Post subject: |
|
AS CMTG said, unlike a text box, the text area cannot be controlled via maxlength. You can, however, control it via javascript. So if you want to limit the amount of text a user inputs, here's one of many examples:
http://www.dynamicdrive.com/dynamicindex16/maxlength.htm |
_________________ Some people are like slinkys... not really good for anything but they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
|
drums
Toilet Drinker


Joined: 19 Jun 2003 Posts: 234
Location: Portland, OR
|
Posted:
Wed Dec 16, 2009 11:29 am Post subject: |
|
Thansk for clearing it up. I'll try the javascript |
_________________
|
|
|
|
|
drums
Toilet Drinker


Joined: 19 Jun 2003 Posts: 234
Location: Portland, OR
|
Posted:
Wed Dec 16, 2009 12:53 pm Post subject: |
|
I tried the javascript which works fine but I still get a validation error.
So does anyone know how to do this with CSS? That way I can eliminate the maxlength from the textarea.
Thanks, |
_________________
|
|
|
|
|
CMTG
Leg Humper


Joined: 23 Feb 2002 Posts: 5449
Location: /var/log/cabin
|
Posted:
Wed Dec 16, 2009 3:21 pm Post subject: |
|
drums wrote:I tried the javascript which works fine but I still get a validation error.
So does anyone know how to do this with CSS? That way I can eliminate the maxlength from the textarea.
Thanks,
Just delete the maxlength attribute. You don't have to do anything in CSS because it's not having any affect on your textarea anyway. It's an invalid attribute! |
_________________ Pie. I wish I could
constrain my hungry greed but...
Sadly, defeated.
Charlene's Law: There's no such thing as can't.
Charlene's Corollary: Unless it's followed by be arsed.
I write more quotes than a fucking big book of quotes. - Scroobius Pip
http://fedoraproject.org/get-fedora
|
|
|
|
|
drums
Toilet Drinker


Joined: 19 Jun 2003 Posts: 234
Location: Portland, OR
|
Posted:
Wed Dec 16, 2009 3:41 pm Post subject: |
|
Thanks, you're right and I did and all is well. I found a nifty piece of javascript to do it but wish it did more because right now if you reach the max length it freezes you out of the text area meaning you can't do any editing in there like delete text; you can go to other fields and do things but just not in the textarea. I'm going to work on it later to see if I can make it more complete so it either warns or at least returns the cursor functionality in there. It's very similar to the one gregw pointed me to but simpler.
<script language="javascript" type="text/javascript">
<!--
function imposeMaxLength(Object, MaxLen)
{
return (Object.value.length <= MaxLen);
}
-->
</script>
And the HTML
onkeypress="return imposeMaxLength(this, 1000);"
So if you or anyone else has some ideas I'm all ears/eyes... |
_________________
|
|
|
|
|
|
|