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:
- what is gtbfieldid="598"? does jquery add that?
- how to avoid the autocomplete behavior of the browsers in this textfield?
开发者_如何学编程thanks :)
- The - gtbfieldidattribute 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- gtbfielidattributes, 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'}))
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论