Front-End & Daily

autocomplete attribute when first and last names are separated in a form

autocomplete attribute when first and last names are separated in a form

When the "last name" and "first name" are separate in an HTML form (or when they must be separate),
how should the autocomplete attribute be specified?
What happens on actual devices?

I've summarized it.

Conclusion

To conclude,

For last name:autocomplete="family-name"

For first name:autocomplete="given-name".

Sample

However, it is only auto-completed on Safari for iOS and Mac.

Let's give up on Android and Chrome.

I will explain in more detail.

Values suggested by autocomplete

First of all, the values suggested by the autocomplete attribute are

For "Safari" on iOS and Mac, contact values are used,

while for Android, values set in the browser are suggested.

The name fields differ between iOS and Android.

iOS

The iOS contacts have these fields, allowing you to register "Last Name", "Last Name Furigana", "First Name", and "First Name Furigana".

iOS Contacts Name Field

iOS Contacts Name Field Input

Android

Chrome settings have these fields, and there is only one name field.

Android Chrome Settings Name Field

Given this, it's clear that Safari on iOS can auto-complete even if "last name" and "first name" are separated,
but Chrome cannot.

Behavior on actual devices

In fact, when tested on Safari for iOS, it auto-completes perfectly,

iOS Safari autocomplete Last Name

iOS Safari autocomplete First Name

However, on Chrome for Android, although suggestions are displayed, the first character goes into the "last name" field, resulting in "Yama" and "da Taro".

Android Chrome autocomplete Last Name

This is also the case for Chrome on Windows and other platforms.

By the way, even if I inserted a half-width space between "last name" and "first name" in the Chrome settings, it didn't work.

Android Chrome Name Field

Summary

Therefore, in forms where "last name" and "first name" are separated (or must be separated),

the autocomplete attribute should be:

For last name: autocomplete="family-name"

For first name: autocomplete="given-name"

The source code would look like this:

<form>
	<label>姓 <input type="text" autocomplete="family-name"></label>
	<label>名 <input type="text" autocomplete="given-name"></label>
</form>

However, while it auto-completes correctly on Safari for iOS and Mac, it is unlikely to auto-complete on Chrome for Android or Windows.

If you found different behavior in your environment or know a better method, please let me know in the comments.

Comments

After reviewing the content, we will publish it, omitting any personal information.

Enter your name and email address too

Please enter if you would like a reply via email.

We will not disclose any personal information provided. It will only be used for replies.

It will be sent directly. Please confirm and click "Send".

If this was helpful, we appreciate your support!
Any support received will be used for childcare.

Send support via OFUSE


Or support us by buying something from the buttons below
(You don't have to buy the linked product.)

Amazon

Rakuten Ichiba

Yahoo! Shopping

PR

As an Amazon Associate, "Ken" earns from qualifying purchases.

Share

Share on Twitter Share on Facebook Share on LINE Share on Hatena Bookmark