Bug Tracker

Opened 9 years ago

Closed 8 years ago

Last modified 6 years ago

#4389 closed bug (fixed)

$().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:


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)

test.htm (545 bytes) - added by lyndsysimon 9 years ago.

Download all attachments as: .zip

Change History (8)

Changed 9 years ago by lyndsysimon

Attachment: test.htm added

comment:1 Changed 9 years ago by lyndsysimon

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.

comment:2 Changed 9 years ago by lyndsysimon

to clarify, 'maxLength' works, 'maxlength' does not.

comment:3 Changed 9 years ago by dmethvin

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 231.

comment:4 Changed 9 years ago by lyndsysimon

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:


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):


it works properly in all three major browsers.

comment:5 Changed 9 years ago by dmethvin

Hmmm, maybe adding maxlength to jQuery.props would fix this?

comment:6 Changed 8 years ago by dmethvin

Resolution: fixed
Status: newclosed

Fixed in 1.4a1; maxLength is in jQuery.props.

comment:7 Changed 7 years ago by blaisekal@…

This (still? again?) seems to be a problem: http://jsfiddle.net/dcrQg/

Note: See TracTickets for help on using tickets.