Despite it is not a Joomla question, it is still could be a relevant question in many area in Joomla Forms too and can be applied in Joomla, so I try to give a useful working solution (which I've found among a lot of nonworking and old solutions).
So the login form: (should be renamed according to your needs)
<form id="login-form">
<input class="form-control" name="username" placeholder="Username" type="text">
<input class="form-control password" name="password" placeholder="Password" type="text">
<button class="btn btn-lg btn-primary btn-block" name="demo-submit" value="Login" type="Submit">Login</button>
</form>
The useful javascript code: (to include)
<script src="https://terrylinooo.github.io/jquery.disableAutoFill/assets/js/jquery.disableAutoFill.min.js"></script>
And the jQuery script:
<script language="javascript" type="text/javascript">
var $ = jQuery;
$('#login-form').disableAutoFill({
passwordField: '.password',
debugMode: false,
randomizeInputName: true,
callback: function() {
return checkForm();
}
});
function checkForm() {
form = document.getElementById('login-form');
if (form.password.value == '') {
alert('Cannot leave Password field blank.');
form.password.focus();
return false;
}
if (form.username.value == '') {
alert('Cannot leave User Id field blank.');
form.username.focus();
return false;
}
return true;
}
</script>
I tried this and it works even in Chrome where most of the times this autocomplete avoiding solutions fail. I did not try it on all browsers but the author claims it works on all browsers.
The source with all of the info about this is here:
https://github.com/terrylinooo/jquery.disableAutoFill
I hope this can help.
UPDATE - CUSTOMIZED SOLUTION FOR JOOMLA ADMIN LOGIN
Now, the above code works on many forms but not on Joomla admin login. I knew that I will have to take my time to customize the solution on this question to make it a Joomla question. So here is how to disable autofill/autocomplete on the Joomla Admin Login page:
it's relatively simple at the end.
I worked on the template: administrator/modules/mod_login/tmpl/default.php
(create a backup copy of this file to somewhere before edit that, then if you screw up something you can just place back that original file in place) Or, actually the right way is to create a template override of this module default.php file in the template manager of the admin.
1. On the top of the file after the closing php tag ( ?> ) paste the jquery import, just this code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
2. In the username and password input fields, add an attribute (autocomplete="off") (it may sound stupid but it should be there)
3. At the password input field change the type attribute to text ( type= "text" )
4. Then, place the following javascript/jQuery code at the end of the file (after the closing tag of the form **</form>**
):
<script type="text/javascript">
$(function(){
$('#mod-login-username').attr({
'name' : 'mygod',
'type' : 'text',
// 'readonly' : true,
});
$('#mod-login-password').attr({
'name' : 'mygod2',
'type' : 'text',
// 'readonly' : true,
});
});
$('#form-login').on('submit', function(){
$('#mod-login-username').attr('name','username');
$('#mod-login-password').attr('name','passwd');
$('#mod-login-password').attr('type','password');
});
</script>
And that's it, it worked for me without a problem and I could signed in to my admin without problem, autofill was not ignited in the browser (I tried this on Chrome and on Firefox). I hope that it will work for you too and you can confirm this for me at your side. (it still could be simplified a lot, but at least it works now).
And just showing the result visually:

Firefox - Autocomplete is not ignited and the Joomla authentication works too. It's the same in Chrome.
autocomplete="nope"