autocomplete attribute on AutoComplete widget

1 Answer 49 Views
AutoComplete
David
Top achievements
Rank 2
David asked on 15 Nov 2021, 03:44 PM

How can I set the HTML autocomplete attribute on an input which uses Kendo UI AutoComplete widget to a value other than "off"? 

So far, I have tried the following code: 


<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Untitled</title>

  <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.3.1109/styles/kendo.common.min.css">
  <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.3.1109/styles/kendo.rtl.min.css">
  <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.3.1109/styles/kendo.default.min.css">
  <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.3.1109/styles/kendo.mobile.all.min.css">

  <script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
  <script src="https://kendo.cdn.telerik.com/2021.3.1109/js/angular.min.js"></script>
  <script src="https://kendo.cdn.telerik.com/2021.3.1109/js/jszip.min.js"></script>
  <script src="https://kendo.cdn.telerik.com/2021.3.1109/js/kendo.all.min.js"></script></head>
<body>
  <input type="text" id="countries" autocomplete="one-time-code" />
  <script>
  $(function(){
      
      var countries = [ "Australia", "Canada", "United States of America"];
    
      var countriesDataSource = new kendo.data.DataSource({
        data: countries
      });
      $('#countries').kendoAutoComplete({
        dataSource: countriesDataSource
      });
  });
  </script>
</body>
</html>

But if you see the screenshot, no matter the HTML markup, the input gets the autocomplete="off" attribute (and value). Guessing this is part of the autocomplete widget?

I am trying to get round the Chrome issue reported here where the previous input to an input[type=password] is autofilled with a username / email.

So want to know how to set the autocomplete attribute on a Kendo-ified AutoComplete input, to a value of my choice.

Alternatively, any solid method of avoiding Chrome autofill on the Kendo UI AutoComplete widget would be greatly appreciated. 

Thanks in advance 

 

 

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 18 Nov 2021, 10:19 AM

Hello David,

I would suggest you try using the jQuery attr method as in the example below:

$('#countries').attr('autocomplete', 'CUSTOM')

Here is a Dojo example where this is demonstrated. 

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

David
Top achievements
Rank 2
commented on 18 Nov 2021, 10:29 AM

Hi Neli, 

Many thanks for your response, along with Dojo example.

For some reason, I was under the impression that one was not allowed to edit this attribute with JS (thought I read it some place, but unable to find any reference now). I will give it a go in my app and see how it rolls.

Hope I can stop e.g. Chrome from deciding how to autofill my form fields; very annoying when I have a search box on same page as reset password form, where the search box comes before, and thus I get autofill for a username / email address in the search field (which is my Kendo-ified AutoComplete control). 

Many thanks, once again :-) Have a great day. 

Regards, 

David

Tags
AutoComplete
Asked by
David
Top achievements
Rank 2
Answers by
Neli
Telerik team
Share this question
or