Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable autocomplete with v-form

I want to disable chrome autocomplete in my v-form. How do I do that? I don't see a autocomplete property on the v-form.

https://next.vuetifyjs.com/en/api/v-form/

While it is a property on a normal html form

https://www.w3schools.com/tags/att_form_autocomplete.asp
like image 384
anonymous-dev Avatar asked Dec 02 '20 21:12

anonymous-dev


People also ask

How do you disable browser autocomplete on web form field?

This can be done in a <form> for a complete form or for specific <input> elements: Add autocomplete="off" onto the <form> element to disable autocomplete for the entire form.

How do I turn off autocomplete in textbox?

Click the Display tab. Do one of the following: To enable AutoComplete for the text box, select the Enable AutoComplete check box. To disable AutoComplete for the text box, clear the Enable AutoComplete check box.

How do I remove input from suggestions?

To get rid of unwanted autofill suggestions in Chrome, highlight the suggestion you want to clear by hovering your mouse over it, then press the "shift" and "delete" keys at the same time.


Video Answer


3 Answers

By setting autocomplete="username" and autocomplete="new-password" on v-text-field you can actually turn off the autocomplete in chrome.

here is a code that worked for me:

       <v-form lazy-validation ref="login" v-model="validForm" @submit.prevent="submit()">
            <v-text-field
              v-model="user.email"
              label="Email"
              autocomplete="username"
            />
            <v-text-field
              v-model="user.password"
              label="Password"
              type="password"
              autocomplete="new-password"
            />
            <v-btn type="submit" />
        </v-form>

Edit: autocomplete isn't set as a prop in vuetify docs but if you pass something to a component which isn't defined as prop in that component, it will accept it as an attribute and you can access it through $attrs.

here is the result of the above code in vue dev tools:

autocomplete as inspected in vue dev tool

and here is the rendered html:

autocomplete as inspected in the html

like image 119
hamid niakan Avatar answered Oct 19 '22 20:10

hamid niakan


I wasn't able to get autofill disabled with the above methods, but changing the name to a random string/number worked.

name:"Math.random()"

https://github.com/vuetifyjs/vuetify/issues/2792

like image 3
Justin C. Avatar answered Oct 19 '22 19:10

Justin C.


use autocomplete="off" in <v-text-field

<v-text-field
   autocomplete="off"
/>
like image 3
eDiKay Avatar answered Oct 19 '22 18:10

eDiKay