setAttribute('maxlength', 5); on input doesn't work

Atom RSS

This site heavily relies on bug reports created by its readers. Anyone can report a bug and be published.

Main navigation:

Search reports by browser:

Setting of the maxlength attribute with Javascript using the setAttribute() function doesn't work in Explorer and Opera, while setting other attributes like size works.

Test page Workaround is not included
Reported by: Henning Jungkurth.

(Orphaned), Explorer 5-6 Windows, Explorer Mac, Opera | Reported on 21 February 2005.


(Add your own)

Posted by Peter Siewert on 25 February 2005


Setting maxlength with Javascript using the setAttribute() function will work in Opera if the HTML object has not been added to the DOM model yet. Like this:
var test = document.createElement('INPUT')
test.type = 'text' = 'setAtt'
test.setAttribute('maxlength', 5);

This still doent work for IE

Posted by Mark Deal on 1 March 2005


The 'l' needs to be capitalised. Use setAttribute('maxLength',5) and it will work fine in IE.

Posted by xarfox on 2 March 2005


capitalizing the L worked, AWESOME!!

Posted by Hennign Jungkurth on 5 March 2005


Thanks for solving this. I've updated the test page.