Turn off autocomplete textfield

How can I turn off my textfield

Temporarily I use this to clear out my fields (username and password) in onShow :


setTimeout(function () { $$(prefix + "-form").clear();}, 500);

Need delay for seconds and I try something like this :


var uname = document.getElementsByClassName("username");
var upass = document.getElementsByClassName("password");
uname.setAttribute( "autocomplete", "off" ); 
upass.setAttribute( "autocomplete", "off" ); 

Still doesn’t work, any solution how to clear all fields even though browser remember the credential

var uname = document.getElementsByClassName("username");
var upass = document.getElementsByClassName("password");

uname[0].setAttribute( "autocomplete", "off" );
upass[0].setAttribute( "autocomplete", "off" );

OR

uname.forEach(function(elem){
   elem.setAttribute( "autocomplete", "off" ); 
});
upass.forEach(function(elem){
   elem.setAttribute( "autocomplete", "off" ); 
});

It’s a bit easier to provide this attribute via the related attributes property of a text control, which allows settings any HTML attribute to an input:

view:"text", { attributes:{ autocomplete:"off" }}

If you want to disable autocompleting for all the element in a form at once, you can use the form’s elementsConfig setting:

view:"form", elementsConfig:{
    attributes:{autocomplete:"off"} 
}

Please, check the related snippet: https://webix.com/snippet/d5d9ccf1

Thanks Intrega, Helga

I tried all this doesn’t work, always autofill the input text.

looks like it is related to login fields How to turn off form autocompletion - Web security | MDN

this works for me:

“autocomplete”: “new-password”

{
“view”: “text”,
“name”: “paswdweb”,
“type”: “password”,
“label”: “Password”,
“attributes”: {
“maxlength”: 30,
“autocomplete”: “new-password”
}

Yes perfect ! thanks

For Chrome version 63+, use:

view:"form", 
elementsConfig:
{
    attributes:
    {
        autocomplete:"disabled"
    }
},

```