| Joshie76 on Jun 25, 2002 at 3:26:02 AM | No Rating |
Smart. I wasn't aware of the defaultValue property before, very handy! Thanks. |
| chipple on Jun 24, 2002 at 9:45:39 PM | No Rating |
| Oops I meant "Joshie76's code". :) |
| chipple on Jun 24, 2002 at 9:41:41 PM | No Rating |
Here's my take at enabling resetting on textareas using this behaviour. This is a modification of 's code.
<html> <head> <title> Textarea reset test... </title> <style type="text/css"> textarea {behavior: url(maxlength.htc)} </style> <script type="text/javascript"><!-- function fResetTextarea (oForm) { for (var i = 0; i < oForm.length; i++) { if (oForm.elements[i].type == "textarea") oForm.elements[i].value = oForm.elements[i].defaultValue; } } //--></script> </head> <body> <form onReset="fResetTextarea(this);"> <textarea maxlength="10"></textarea><br/> <input type="text"/><br/> <input type="reset" /> </form> </body> </html>
Good luck!, |
| Joshie76 on Jun 24, 2002 at 1:37:32 AM | No Rating |
Thanks again Mack. I thought that problem would turn out to be a browser bug, shame. Thanks for trying though.
Josh |
| mack on Jun 21, 2002 at 11:06:15 AM | No Rating |
I've installed IE6 now. After trying in vain to make my HTC work with the reset button, i tried another experiement. This time, I created an empty file called "test.htc" and assigned it as the behavior rather than maxlength.htc. The reset button still doesn't work. My guess is that IE6 has a bug in it regarding behaviors. Or it just doesn't support them in the same way as IE5 did. |
| mack on Jun 21, 2002 at 8:13:44 AM | No Rating |
Let me see if I can get an IE6 machine here. I tried your test page in IE5 and it worked as expected. |
| Joshie76 on Jun 21, 2002 at 1:45:25 AM | No Rating |
I've set up a test at http://www.hrmsoftware.com/test/behaviors/textarea.htm.
|
| Joshie76 on Jun 21, 2002 at 1:40:36 AM | No Rating |
Thanks Mack.
I just tried your test HTML in the same directory and it still didn't clear. I'm using IE6 on W2K and the same happens on IE6 with XP Pro. Just tested it on IE5.5 on W2K and it doesn't work there either. The maxlength is working fine, the textarea just won't reset...
help! |
| mack on Jun 20, 2002 at 12:50:33 PM | Rating: 5 |
Behaviors do not work in Netscape or Mozilla. They are restricted to Internet Explorer 5+ at the moment. Maybe someday, the W3C will incorporate behaviors as a standard.
Here is a simple example of how the htc file is incorporated:
<html> <head> <title>test</title> <style type="text/css"> textarea {behavior: url(maxlength.htc)} </style> </head> <body> <form> <textarea maxlength="30"></textarea> <input type="reset" /> </form> </body> </html>
I have this test.htm file in the same directory as the .htc file. The reset button clears the textarea as expected. I can't say what your problem could be unless you actually have a default value in the textarea when you expect to have none. |
| Joshie76 on Jun 20, 2002 at 1:56:49 AM | No Rating |
I've run into some trouble with this script. It seems when you reset your forms the textareas no longer reset!
Any ideas? Help! |
| Ravi Kumar on May 30, 2002 at 3:54:17 AM | Rating: 1 |
| any one can give me how ti use it in HTML coding |
| mini75 on Nov 8, 2001 at 10:22:53 AM | No Rating |
| I am not sure if I have understood correctly how to use these functions. What and where am I suppose this code. Can you please help. |
| amul_luma on Jul 2, 2001 at 12:03:06 AM | No Rating |
Is this maxlength for textarea works in netscape |
| poojarajdev on Feb 12, 2001 at 2:34:12 AM | Rating: 1 |
Hi!
This code is not working fine with me.I dont know what is the problem. I downloaded the file "htc" and added it in css as specified in the article.
What could be the problem please tell, somebody? |
| Jovan on Jan 20, 2001 at 4:21:47 PM | Rating: 4 |
| I have tried this script it works ok, but I have problems with the pictures on the bottom of my page www.doktor.co.yu/formular.html Sometimes one of two pictures is not displayed (after refresh). On other pages everything is ok, so I think that there is problem in this script or IE? |
| mack on Jan 25, 2000 at 8:45:27 AM | No Rating |
I performed the test you mentioned and was not able to paste more than 55 chars. Are there any other changes you made which might affect the test? I'd like to fix any problems since people may be using this on production sites.
Basically, I pulled the page and HTC off of this site and altered the maxlength attribute to "55". It seems to work fine as far as I can tell. |
| jparrish on Jan 7, 2000 at 8:48:17 AM | Rating: 4 |
Good, but one minor problem....change the maxlength to 55, then cut-n-paste the following 0123456789. It will actually let you paste 6 times or a total of 60 characters. |
| mack on Oct 7, 1999 at 4:57:17 PM | No Rating |
| I cannot re-create this error. Is there any more information you can give me? Was it on the sample within the article or on your own page? |
| pbienick on Oct 6, 1999 at 5:23:03 AM | Rating: 3 |
Nice but blows up when I try to paste text. I get the following error:
line: 26 Error: 'window.clipboardData.getData(...)' is not an object
I am using IE 5, full version: 5.00.2314.1003CO |
| Yachoo on Oct 6, 1999 at 2:01:37 AM | Rating: 4 |
| asdfasdfasdfdasfasdfasdfasdfasdfasdfdassdafasdfasfasdfdasfadsfasdf |