admin管理员组文章数量:1279234
is it possible to remove a maxlength attribute from an element? I thought that setting it to 0 would work, but it seems like FF4 then prevents entering anything. /
I've heard that setting it to -1
does trigger an error and removeAttribute
does not work either.
is it possible to remove a maxlength attribute from an element? I thought that setting it to 0 would work, but it seems like FF4 then prevents entering anything. http://jsfiddle/hMc4y/
I've heard that setting it to -1
does trigger an error and removeAttribute
does not work either.
2 Answers
Reset to default 7Using "removeAttribute('maxLength')" should work fine; perhaps the surprise is that the attribute name must be "maxLength
" with an uppercase "L". Consider:
<form name="f">
<input name="t" type="text" maxlength="5"/>
</form>
<script type="text/javascript">
var t = document.f.t;
alert(t.maxLength); // 5
t.removeAttribute('maxLength');
alert(t.maxLength); // 524288 (on Chrome/10.0.648.134)
</script>
removeAttribute works for me in both Firefox 3.5 and Chrome.
本文标签: javascriptRemoving the maxlength attributeStack Overflow
版权声明:本文标题:javascript - Removing the maxlength attribute - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741253734a2366274.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论