@Nidihsa You cannot reliably force a browser to populate a particular value or to honor autocomplete="off". The browser owns the autofill behavior.
AEM Forms can, however, provide the correct semantic hints:
- First name:
given-name - Last name:
family-name - Full name:
name
If the priority is data quality rather than autofill
Do not depend on browser autofill settings as the data-quality control. Add validation in both places:
Client-side validation
Display a warning or validation error when:
normalized(firstName) == normalized(lastName)
For example:
Please verify that your first name and last name are different.
Do not reject every equal pair automatically. Some users may legitimately have a single name or identical name parts, depending on the business and regional requirements.
Server-side validation
Repeat the validation after submission. Client-side validation can be bypassed and should not be the only protection for submitted data.
A stronger design is to add a final review step showing:
First name: {{firstName}}
Last name: {{lastName}}
Require the user to confirm the displayed values before the final submission.
Can you disable autofill?
You can request that browsers do not autofill the form:
<form autocomplete="off">
<input autocomplete="off">
<input autocomplete="off">
</form>
However, this is still not a universal enforcement mechanism. Browsers and password managers may override or interpret the setting differently, particularly for fields they identify as names, addresses, credentials, or payment data.
Therefore:
- Use correct semantic tokens when autofill is desirable.
- Use
autocomplete="off" as a mitigation when autofill is causing unacceptable risk. - Still validate the submitted values server-side.
- Do not use randomized field names or misleading tokens as a workaround; that can damage accessibility, integrations, and future browser behavior.