Side navigation
#4389 closed bug (fixed)
Opened March 19, 2009 09:51PM UTC
Closed December 16, 2009 04:15AM UTC
Last modified March 14, 2012 02:36PM UTC
$().removeAttr('maxlength') set maxlength to 0 in IE7
Reported by: | lyndsysimon | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | core | Version: | 1.3.1 |
Keywords: | removeAttr maxlength | Cc: | |
Blocked by: | Blocking: |
Description
When you use .removeAttr, IE does not let you enter anything in the field. IE Dev Toolbar on IE7 reports that maxlength=0.
Attachments (1)
Change History (7)
Changed March 20, 2009 01:45PM UTC by comment:1
Changed March 20, 2009 01:45PM UTC by comment:2
to clarify, 'maxLength' works, 'maxlength' does not.
Changed March 21, 2009 01:47AM UTC by comment:3
Can you clarify what the original problem was? Were you trying to "clear" maxlength so that the field wasn't constrained?
NB: There is actually a
.maxLength*property* on input elements; IE and Firefox do not treat the "no max length" the same way. I seem to recall that IE uses -1 and FF uses 2^31.
Changed March 21, 2009 05:13PM UTC by comment:4
Perhaps I am using it in the wrong way, then. My initial frustration was with removing the maxlength from a text input, to instead color the field when the maximum length was exceeded - as part of an unobtrusive form validation script.
<input type='text' id='target' maxlength='3'>
The above limits the field to 3 characters - no more may be entered. Now if we execute this:
$('input#target').removeAttr('maxlength');
The limitation is removed in Firefox (so the field now has no maximum length), but it is changed to 0 in IE7, so you cannot input any characters at all. If I use this instead (notice capitalization):
$('input#target').removeAttr('maxLength');
it works properly in all three major browsers.
Changed May 16, 2009 03:08PM UTC by comment:5
Hmmm, maybe adding maxlength to jQuery.props would fix this?
Changed December 16, 2009 04:15AM UTC by comment:6
resolution: | → fixed |
---|---|
status: | new → closed |
Fixed in 1.4a1; maxLength is in jQuery.props.
Changed October 25, 2010 01:38PM UTC by comment:7
This (still? again?) seems to be a problem: http://jsfiddle.net/dcrQg/
After further testing, it appears that .removeAttr('maxLength') works in both IE7 and Ffx 3.0.6. Still not correct behavior, but it solves my immediate issue.