Jquery to remove autocomplete from all project forms

0

Putting this jqery instruction on each page removes the autocomplete forms but only from that page:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">

    $("form").attr('autocomplete', 'off');

</script>

The problem is that I reload the pages in the project by means of ajax so the dynamically created forms do not apply the autocomplete="off" I had thought to put the isntruccion $ ("form"). on so that the created forms dynamically add the autocomplete property off. I've tried it this way and it does not work.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">

$(document).on( "ready", function() {
$("form").attr('autocomplete', 'off');
});


</script>

What solution could I have?

    
asked by DjEmilio84 13.07.2018 в 11:41
source

2 answers

1

For elements that are at the beginning of the loading of the page, what you have is fine, but for the dynamic ones in the ajax you need to put this.

$.ajax({
  /***/
  success: function(){
     $("form").attr('autocomplete', 'off');
  },
})
    
answered by 13.07.2018 в 12:55
0

I found a solution. with this code in the header of the page, it removes the autocomplete of all the project's inputs, whether they are in a form or not, it is created in the client or server part.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js">
$(document).ready(function(){

  $("body").on("focus","input",function(event){
    $(this).attr('autocomplete', 'off')
  });

});


</script>
    
answered by 13.07.2018 в 13:54