henryaaron
henryaaron

Reputation: 6192

WebKit-specific attribute to disable the AutoFill function on a certain field

Is there some kind of attribute that'll block Safari and Chrome's address and contact info on a certain HTML <input>.

I have an EmailSubject field in one of my forms and Safari (iOS and dekstop) treats it as an email input and enters the user's email address in the field.

I am definitely not looking to disable autocomplete, not even a jQuery code that'll disable it only on WebKit browsers, just looking for some sort-of built in WebKit attribute for the input itself. Google couldn't help with on this one.

Upvotes: 2

Views: 309

Answers (1)

dsuess
dsuess

Reputation: 5347

Sometimes I notice this strange behavior on Chrome and Safari, when there are password fields in the same form. I guess, the browser looks for a password field to insert your saved credentials. Then it autofills (just guessing due to observation) the nearest textlike-input field, that appears prior the password field in DOM. This may also appear for email, home address etc. As the browser is the last instance and you can not control it, sometimes even autocomplete=off would not prevent to fill in credentials. This readonly-fix worked for me.

 <!-- fix browser address/password etc fill in: 
     set readonly and set writeble on focus (click and tab) -->
 <input type="search" readonly  
     onfocus="$(this).removeAttr('readonly');"/>

Upvotes: 1

Related Questions