Let’s first look at the implementation of the input password input box based on JS code to change the password to black dots and cipher text. The specific code is as follows:
html code
<form id="login-form" method="post" onsubmit="return checkForm()"> 输入密码<input type="password" id="input-password"> <input type="hidden" id="md5-password" name="password"> <button type="submit">Submit</button> </form>
js code
function checkForm() { var input_pwd = document.getElementById('input-password'); var md5_pwd = document.getElementById('md5-password'); // 把用户输入的明文变为MD5: md5_pwd.value = toMD5(input_pwd.value); // 继续下一步: return true; }
Supplement: JS obtains multiple names with the same name The value of the input box
Initially, document.all.id.length was used to obtain the number of input boxes, but sometimes it was normal and sometimes it showed undefined. The effect was not very good. Online information said that document.all was not compatible. Of all browsers, it seems to only support IE now.
The solution is as follows:
var els =document.getElementsByName("search"); for (var i = 0, j = els.length; i < j; i++){ alert(els[i].value); }
The above is the JS code introduced by the editor to implement the input password input box to change the password to black dots and ciphertext. I hope It will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!
For more JS implementation methods to obtain the values of multiple input boxes with the same name, please pay attention to the PHP Chinese website for related articles!