#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: |
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 (8)
Changed 14 years ago by
comment:1 Changed 14 years ago by
comment:3 Changed 14 years ago by
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 14 years ago by
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.
comment:6 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in 1.4a1; maxLength is in jQuery.props.
comment:7 Changed 12 years ago by
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.