I have this simple form:
class PagoDesde(forms.Form):
from django import forms as f
desde = f.DateField(input_formats=['%d/%m/%Y'])
In my template:
{{ form.desde }}
And has associated a jqueryui.datepicker in the document.ready
$("#id_desde").datepicker();
The html result is:
<input type="text" id="id_desde" name="desde"
class="hasDatepicker" gtbfieldid="598"/>
And it works great, but I have
2 questions:
gtbfieldid="598"
? does jquery add that?thanks :)
The gtbfieldid
attribute is added dynamically by the Google Toolbar to the <input>
and <select>
tags that it thinks it can fill in for you.
If you add the autocomplete="off"
attribute to the <form>
tag that contains them, then the Google Toolbar will not add these gtbfielid
attributes, and its autofill functionality will not be available when filling out that form.
Both of these attributes are non-standard XHTML, so your form will fail validation but if this autofill behavior is causing problems for your visitors, then adding the autocomplete="off"
attribute is the only workaround to stop the Google Toolbar from manipulating your form elements and offering to try to fill it in for the user.
Here's how you'd set the autocomplete attribute (in django):
class PagoDesde(forms.Form):
from django import forms as f
desde = f.DateField(input_formats=['%d/%m/%Y'],
widget=forms.TextInput(attrs={'autocomplete': 'off'}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With