I want to disable autocomplete for all inputs using jquery ui datepicker without doing this to every input manually.
How could be this done?
views:
138answers:
3
A:
Try this:
<input type="text" name="field1" value="" autocomplete="off" />
Makram Saleh
2010-05-04 12:32:50
I don't want to write this to every input manually
Ibrahim Hussein
2010-05-04 12:36:55
+1
A:
Assign a css class to your datepickers, i.e. "datepicker", then do the following:
$(".datepicker").attr("autocomplete", "off");
GenericTypeTea
2010-05-04 12:33:22
I am putting this code in my main layout, i think it's being executed on current inputs in the DOM. When loading an ajax form the newly created inputs still has autocomplete on.
Ibrahim Hussein
2010-05-04 12:56:09
A:
try this:
$(".datepicker").live( 'focus' , function() {
$(this).attr("autocomplete", "off");
});
UPDATE:
$('.datepicker').live('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!
aSeptik
2010-05-04 14:28:55
For some reason this code works only after first focus for the input.I changed 'focus' to 'hover' and it works.Thanks
Ibrahim Hussein
2010-05-06 14:48:42