shebelaw shebelaw - 1 year ago 188
Javascript Question

setting maxlength of textbox with javascript or jQuery

I want to change the maxlength of a textbox with javascript or JQuery: I tried the following but it didn't seem to help:

var a = document.getElementsByTagName('input');
for(var i=0; i<a.length; i++) {
if((a[i].type!= 'radio')||(a[i].type!= 'checkbox'))
a[i].maxlength = 5;


What am I doing wrong?

Jay Jay
Answer Source

Not sure what you are trying to accomplish on your first few lines but you can try this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download