ILIAS ILIAS - 1 month ago 16
HTML Question

Clear password field

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


The above is a password field which for some reason, is automatically filled only in Mozilla (not in Chrome and IE11). Obviously it keeps the value field from previous trials. I tried so much to clear this field. The only way I can manage it, is through the following:

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


Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,

$(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('');
});


Nor, this works...
Of course, I tried the obvious:

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


which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?

Thank you

Answer

I found it!!

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

Hopefully, the above works. However, I cannot give a satisfactory explanation why this small delay solves the problem...Most probably, it is a Mozilla bug.