Want to prevent browsers from auto-filling your form fields? While browser autocomplete can be convenient, there are times when you need users to manually enter their information.
This guide will show you how to disable autocomplete functionality for specific forms or fields using PHP code snippets.
Before implementing autocomplete restrictions, it’s important to understand:
- Browser settings typically take precedence over HTML attributes and JavaScript
- The
autocomplete="off"
attribute signals your preference to browsers - Modern browsers generally respect this setting, but some may override it
- Browser support varies (check the MDN compatibility chart)
Setting Up Your Form
First, you’ll need to create your form and add your form fields. If you need help with this, please review our guide on creating your first form.
Disabling Autocomplete
You can disable autocomplete either for an entire form or for specific fields. Here are both approaches:
Disable Autocomplete for All Fields in a Form
Disable Autocomplete for Specific Fields
The snippet below will specifically target the Email field. To target a different field type, the filter (wpforms_field_properties_email
) would need to be adjusted.
Remember to update any of the snippets above to match your own form and field IDs. If you need help in finding these IDs, please check out our guide on finding form and field IDs.
For background on the autocomplete attribute and approaches to turning it off, please see MDN’s documentation.
And that’s all you need in order to disable the browser autocomplete for your WPForms. Next, would you like to disable the Add Form button on the classic editor? Try out our tutorial on How to Remove “Add Form” button from TinyMCE editor.