Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
HTML

HTML5: Fix Autofill That Fills the Wrong Field Because of Missing autocomplete Attributes

- 31.08.26 - ErcanOPAK

🧩 The Browser Fills In the Wrong Field Every Single Time

A checkout form has separate fields for billing and shipping address, and the browser’s autofill keeps putting the wrong data in the wrong field – or ignoring the form entirely – frustrating users who expect one-click autofill to just work like it does everywhere else.

🐞 The Problem

<input type="text" name="street1" placeholder="Billing Street">
<input type="text" name="street2" placeholder="Shipping Street">
<!-- No autocomplete attributes at all - the browser has to
     GUESS what each field is for based on name/placeholder,
     and often guesses wrong or refuses to fill anything. -->

🔍 Why This Happens

Modern browsers rely primarily on the HTML autocomplete
attribute - a standardized vocabulary (like "given-name",
"street-address", "cc-number") - to know exactly what each field
represents. Without it, heuristics based on name/id/placeholder
text are a fallback of last resort and are notoriously unreliable,
especially for forms with more than one address (no reliable way
to guess "billing" vs. "shipping" from a generic label alone).

✅ The Fix: Add Explicit autocomplete Attributes to Every Field

  • Use the standardized token vocabulary for every relevant field: autocomplete="given-name", "email", "tel", "cc-number", etc. — these are defined by the HTML spec and recognized consistently across browsers.
  • For forms with MULTIPLE address groups, prefix the section: autocomplete="shipping street-address" vs. autocomplete="billing street-address" — this is the specific mechanism that tells the browser which group a field belongs to.
  • Use autocomplete="off" deliberately only for fields that genuinely should never autofill (a one-time coupon code) — applying it broadly “to be safe” actively breaks the experience for password fields and address forms alike.

📦 Correct Version

<input type="text" name="street1"
       autocomplete="billing street-address">
<input type="text" name="street2"
       autocomplete="shipping street-address">
<input type="email" name="email" autocomplete="email">
<input type="tel" name="phone" autocomplete="tel">

Browsers don’t read your placeholder text the way a human does — the autocomplete attribute is the actual contract, and every field without one is a guess the browser is free to get wrong.

— Frontend Architect

Related posts:

Native Lazy Loading

Native Lazy Loading

HTML5 Lazy Loading Images — Zero-Effort Performance Gains

HTML5 Lazy Loading Images — Zero-Effort Performance Gains

HTML5: Fix a Native input type='date' Field Showing the Wrong Date by One Day Because the Value Was ...

HTML5: Fix a Native input type='date' Field Showing the Wrong Date by One Day Because the Value Was ...

Views: 8
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

CSS: Fix a Sticky Header That Stops Sticking Inside a Scrollable Parent
Git: Recover a Stash You Accidentally Dropped

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com