Home / Admin / How to Disable Browser Autocomplete for Form Fields – all fields
Duplicate Snippet

Embed Snippet on Your Site

How to Disable Browser Autocomplete for Form Fields – all fields

<10
Code Preview
php
<?php
/**
 * Disable form autocomplete for all fields on a specific form 
 *
 * @link   https://wpforms.com/developers/disable-browser-autocomplete-for-form-fields/
 */
function wpf_dev_disable_form_autocomplete( $form_atts, $form_data ) {
      
    // This check will only form autocomplete for Form #11.
    // Removing this check would disable autocomplete on ALL forms.
 
    if ( absint( $form_data[ 'id' ] ) !== 1277 ) {
        return $form_atts;
    }
  
    $form_atts[ 'atts' ][ 'autocomplete' ] = 'off';
  
    return $form_atts;
}
 
add_filter( 'wpforms_frontend_form_atts', 'wpf_dev_disable_form_autocomplete', 10, 2 );

Comments

Add a Comment