Disable autocomplete for all jquery datepicker inputs

前端 未结 5 1718
余生分开走
余生分开走 2020-12-03 10:42

I want to disable autocomplete for all inputs using jquery ui datepicker without doing this to every input manually. How could be this done?

相关标签:
5条回答
  • 2020-12-03 10:58

    Try this:

    <input type="text" name="field1" value="" autocomplete="off" />
    
    0 讨论(0)
  • 2020-12-03 11:01

    try this:

    $('.datepicker').on('click', function(e) {
       e.preventDefault();
       $(this).attr("autocomplete", "off");  
    });
    

    in anycase you have not mentioned in your question that this is coming from an ajax call!

    0 讨论(0)
  • 2020-12-03 11:04

    This works for me perfectly.

          $("#autocmpldisablechk").click(function () {
    
            if (!$(this).is(":checked")) { // enable autocomplete
    
                $("#autocomplete").autocomplete({
                    disabled: false
                });
    
            }
            else { // disable autocomplete
                $("#autocomplete").autocomplete({
                    disabled: true
                });
    
            }
        });
    
    0 讨论(0)
  • 2020-12-03 11:07

    Assign a css class to your datepickers, i.e. "datepicker", then do the following:

    $(".datepicker").attr("autocomplete", "off");
    
    0 讨论(0)
  • 2020-12-03 11:14

    This works for me (It was tested on Chrome v70.0.3538.110):

                $("#dtpckr([readonly])").datepicker()
                .focus(function() {
                    $(this).prop("autocomplete", "off");
                    //              return false;
                });
    
    0 讨论(0)
提交回复
热议问题