skip to Main Content

I want to disable previous search suggestions in my site.
I use Elementor search form.
I can edit it from the plugin editor but I can’t find the file where I can add the attribute.

2

Answers


  1. to do that you will need to follow these steps:

    1. Give your search form an id or class name (for example i will give my form a class name: tho-auto-off)

    2. Insert an HTML code element, and put in this code:

      <script>
       jQuery(".tho-auto-off input").focus(function(){
          jQuery(this).attr('autocomplete', 'off');
       });
      </script>
      
    3. Save and enjoy.

    In case of this guide is not clearly enough for you – i have record a guide video for this here.

    Login or Signup to reply.
  2. Add this code into your theme function.php file it will add autocomplete=’off’ attribute

    class Elementor_Forms_Input_Classes {
    
    
    
        public function __construct() {
            // Add class attribute to form field render
            add_filter( 'elementor_pro/forms/render/item', [ $this, 'maybe_add_css_class' ], 10, 3 );
    
            add_action( 'elementor/element/form/section_form_fields/before_section_end', [ $this, 'add_css_class_field_control' ], 100, 2 );
        }
        public function add_css_class_field_control( $element, $args ) {
            $elementor = ElementorPlugin::instance();
            $control_data = $elementor->controls_manager->get_control_from_stack( $element->get_name(), 'form_fields' );
        
            if ( is_wp_error( $control_data ) ) {
              return;
            }
        
          public function maybe_add_css_class( $field, $field_index, $form_widget ) {
                $form_widget->add_render_attribute( 'input' . $field_index, 'autocomplete', 'off' );
              $form_widget->add_render_attribute( 'select' . $field_index, 'autocomplete', 'off' );
            return $field;
          }
        }
        new Elementor_Forms_Input_Classes();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search