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.

Comments

(Add your own)

Posted by Peter Siewert on 25 February 2005

1

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'
test.name = 'setAtt'
test.setAttribute('maxlength', 5);
document.getElementsByTagName('FORM')[0].appendChild(test)

This still doent work for IE

Posted by Mark Deal on 1 March 2005

2

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

Posted by xarfox on 2 March 2005

3

capitalizing the L worked, AWESOME!!

Posted by Hennign Jungkurth on 5 March 2005

4

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