Browser prevent the automatic generation of fill and Echo have been saved account solutions

A customer recently encountered problems, login and password boxes do not automatically fill generations already saved passwords, add a thought in the input box

<input type="text" name="login_name" value="" autocomplete="off" placeholder="请输入用户名"/>

 

Get away, I did not expect this shield can only enter history, saved user information in Firefox or so stubborn, as shown:

 

 

 

Or to prompt echo, it has been kept off other accounts, online stroll around, or did not answer a clearly white, and later through repeated testing,

Find the input box is automatically echoed type text and password will trigger Firefox browser,

Online also had to add onfocus event on the input box to change the input box type of program:

<input type="text" onfocus="this.type=password" />

  

But logic is not tight, I come back to delete the wrong password, it will echo out, after the form is submitted will refresh, and finally through continuous attempts, the solution is given as follows:

 

 

// When the login and password input box to search box type is not triggered 
<input type = "search" name = "login_name" value = "" autocomplete = "off" placeholder = " Please enter your user name" /> 
<the iNPUT of the type = "Search" the above mentioned id = "password" name = "login_passwd" value = "" AutoComplete = "OFF" placeholder = "Please enter your password" /> 
... 
// 
<Script of the type = "text / JavaScript "> 
        $ (the Document) .ready (function () { 
           // refresh the form, the page will re-initialize the password box type changed to Search 
           // js here to use native code, jQuery does not have permission to change the input box type attribute 
           document.getElementById ( 'password') the setAttribute ( 'type', 'Search');. 
        });
       // to set the value of its type by the length of the password input box 
       // password prevent the echo back delete 
        the jQuery ( "# password") the bind ( "keyUp", function () {. 
        Var = Self the this;  
        // add the purpose is to delay executing the event such as keyup
        $ .setTimeout (function () {
        var len = $(self).val().length;
        if(len==0){
            document.getElementById('password').setAttribute('type','search');
        }else {
            document.getElementById('password').setAttribute('type','password');
        }
    }, 1);
});
            
</script>

  

Guess you like

Origin www.cnblogs.com/mrwh/p/11220806.html