The above password field, which fo...">

Clear password field

<input name="e_password" id="e_password" type="password" autocomplete="off" />

      

The above password field, which for whatever reason, is only auto-filled in Mozilla (not Chrome and IE11) . Obviously it retains the field of values ​​from previous tests. I've tried so hard to clear this field. the only one I can control is this:

$(document).ready(function(){      
  $('input:text').val(''); 
});

      

Unfortunately, the above resets all other text boxes inside the form, which is not desirable. Besides,

$(document).ready(function(){
    $('input:password').val('');
}); 

      

does not work! Moreover, I tried this:

<div class="abc">   
   <input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>

$(document).ready(function(){
    $('.abc input:text').val('');    
});

      

No, it works ... Of course, I tried the obvious:

$('#e_password').val(''); 

      

which didn't work either. I repeat that the problem only exists in Mozilla. What else can I do?

thank

+3


source to share


8 answers


I found him!

setTimeout(function(){ $('#e_password').val('');}, 50);

      



Hope the above works. However, I cannot provide a satisfactory explanation as to why this small delay solves the problem ... This is most likely a Mozilla bug.

+3


source


document.getElementById("e_password").value = "";

      

or



$('input[type="password"]#e_password').val('');

      

+1


source


$ ("# e_password"). val ('') works for me in firefox. Can you try?

$("#e_password").attr("value","")

      

0


source


Pure Javascript:

document.getElementById('e_password').value = '';

      

Or using jQuery:

$('#e_password').attr('value','');

      

0


source


autocomplete="off"

must be set for the element form

notinput

<form autocomplete="off">
    ....
</form>

      

0


source


I may be wrong, but I think this is not a code problem! These can be saved passwords in the browser. For example, when you open a page in chrome, just check the top-right side of the omnibox and you can click the cross to remove the saved password for that page. I guessed it because you say it only happens in mozilla and not other browsers.

0


source


This is an old question, but I did it in a way that hasn't been mentioned yet. This was done after almost all the suggestions in this thread (except for a timeout as I don't want to add unnecessary delays on my page).

The problem I saw was that the browser was automatically filling in the password field, no value set. So,

$('#password').val("");

      

won't work because the value is already "".

So I did it in 2 lines.

$('#password').val("a");
$('#password').val("");

      

I set the value so I can clear it. Then the browser autocomplete box is cleared.

Hope this helps someone out there!

0


source


FF uses the "change" event on autocomplete (at least in v51).

try something like

// if your input is in html
$(document).ready(function(){ 

/* // if you create input from code like this
$("body").html('<input class="password" type="password" id="e_password">').promise().done(function(){
*/

   $("#e_password").on("change", function() { //append this event
         $("#e_password").off("change"); //optional, depends on your code
         $("#e_password").val(''); //clear
         $("#e_password").attr("value",""); //clear #2 (just to be sure)
    });  

});

      

0


source







All Articles