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
source to share
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.
source to share
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!
source to share
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)
});
});
source to share