jmaxxz Posted December 11, 2008 Share Posted December 11, 2008 I want to make a greasemonkey script to auto magical increase the length of a password field. The site in question has a log form that ties into an active directory server, so passwords can be up to 127 chars in length. However this site has the password field limited to 32chars. (which is too small for my password, so I have been Manuel modifying the html each time I visit this site.) How via javascript would I go about changing the length limit of a password field? Thanks in advanced! Quote Link to comment Share on other sites More sharing options...
adamzap Posted December 11, 2008 Share Posted December 11, 2008 first, get the <input> element of the password field then, do the following with it: pw_field.setAttribute('maxlength', 128); i'm assuming you know how to get the element though. if you know the id, its easy: var pw_field = document.getElementById('pw_field_id') if you dont know the id, you can loop through the inputs on the page: var inputs = document.getElementsByTagName('input'); var pw_field; for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'password') { pw_field = inputs[i]; } } Quote Link to comment Share on other sites More sharing options...
jmaxxz Posted December 11, 2008 Author Share Posted December 11, 2008 first, get the <input> element of the password field then, do the following with it: pw_field.setAttribute('maxlength', 128); i'm assuming you know how to get the element though. if you know the id, its easy: var pw_field = document.getElementById('pw_field_id') if you dont know the id, you can loop through the inputs on the page: var inputs = document.getElementsByTagName('input'); var pw_field; for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'password') { pw_field = inputs[i]; } } Ok thanks, I will give that a shot. I remember trying something similar before butI prolly just screwed up the attribute name. THANKS :) Quote Link to comment Share on other sites More sharing options...
jmaxxz Posted December 12, 2008 Author Share Posted December 12, 2008 Works like a charm! var pw_field = document.getElementById('pw_field_id') var inputs = document.getElementsByTagName('input'); var pw_field; for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'password') { pw_field = inputs[i]; pw_field.setAttribute('maxlength', 127); } } Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.