I want to disable autocomplete
for all inputs using jquery ui datepicker without doing this to every input manually.
How could be this done?
Try this:
<input type="text" name="field1" value="" autocomplete="off" />
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!
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
});
}
});
Assign a css class to your datepickers, i.e. "datepicker", then do the following:
$(".datepicker").attr("autocomplete", "off");
This works for me (It was tested on Chrome v70.0.3538.110):
$("#dtpckr([readonly])").datepicker()
.focus(function() {
$(this).prop("autocomplete", "off");
// return false;
});