Skip to main content

Bug Tracker

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)
  • test.htm (0.5 KB) - added by lyndsysimon March 19, 2009 09:52PM UTC.
Change History (7)

Changed March 20, 2009 01:45PM UTC by lyndsysimon comment:1

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.

Changed March 20, 2009 01:45PM UTC by lyndsysimon comment:2

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

Changed March 21, 2009 01:47AM UTC by dmethvin 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 lyndsysimon 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 dmethvin comment:5

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

Changed December 16, 2009 04:15AM UTC by dmethvin comment:6

resolution: → fixed
status: newclosed

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

Changed October 25, 2010 01:38PM UTC by blaisekal@gmail.com comment:7

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