I want to disable autocomplete login details when i am click on administrator login.stop this prediction

I tried autocomplete ="off",oncopy="return false" onpaste="return false" but nothing work. I know it's a browser property but i need to do this clear website audit. i seen this kind of validation on payment gateway.

  • 1
    Try using autocomplete="nope" – Lodder Nov 1 at 12:32
  • 1
    Ha! I thought you were being snarky. (rather out of character for a moderator) Then I checked it out and that's legitimate advice. developer.mozilla.org/en-US/docs/Web/Security/… This StackOverflow page is so bloated with redundant answers, that it uses pagination: stackoverflow.com/q/2530/2943403 – mickmackusa Nov 1 at 13:35
  • We kinda havta close this one as not a Joomla question, right? I assume that is why Lodder didn't post an answer. – mickmackusa Nov 1 at 13:39
  • autocomplete="nope" is not working for me in Chrome, if the input field name is "username". – Zollie Nov 1 at 14:08
  • But it's really not a Joomla question basically... – Zollie Nov 1 at 14:09

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.

  • I tried this but not worked at all... I changed the input type from password to text. prediction is stopped as well as save password alert. But password showing in text form. i used css to show text to disc form. <style> #txtPassword{ -webkit-text-security:disc; } </style> . But it's not work in firefox. Please help – mohan Nov 13 at 11:59
  • @mohan I updated my answer with the working solution(codes) on this question – Zollie Nov 14 at 9:57
  • thanks @Zollie sir.. It's working. but now another problem arrived that now saved password alert is active again. Can You help on this...? – mohan Nov 17 at 9:32
  • @mohan -- I've checked this a bit further and I also turned on auto save password on my browsers and it is still not popping up when I am submitting my admin credentials when the above code is in my module default.php. So I really do not understand now why it is popping up for you... Are you sure that you precisely follow the steps what I gave above? Thanks. – Zollie Nov 18 at 8:55
  • sorry sir... It's working on administrator login page. Suggest same functionality for Edit account(User edit page). Input code is coming from XML file. and jquery will not work in XML – mohan Nov 19 at 11:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.