0
나는 새 사용자 등록 장고/부트 스트랩 바삭한 형태가 있습니다암호 필드 전에, 장고/부트 스트랩 바삭한 형태로 보이지 않는 입력 필드를 삽입
이from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit
class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput(
attrs={'autocomplete':'off',}))
def __init__(self, *args, **kwargs):
super(UserForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.layout = Layout(
Fieldset(
'',
'username',
'first_name',
'last_name',
'email',
'password'
),
ButtonHolder(
Submit('submit', 'Submit', css_class='button white')
)
)
문제는 브라우저의 자동 완성이 채워 것을을 전자 메일 및 암호 필드.
<div id="div_id_password" class="control-group">
<label for="id_password" class="control-label requiredField">
Password
<span class="asteriskField">*</span>
</label>
<div class="controls">
<input name="password" autocomplete="off" required="" id="id_password"
class="textinput textInput" type="password">
</div>
</div>
가 이제 자동 완성을 끈 것은 작동하지 않는 것을 이해 다음과 같이 암호 주위 장고 바삭한 형태에 의해 생성 된 HTML이다. Djano를 통해이 HTML을 삽입 할 수있는 좋은 방법이 있나요
<div id="div_id_password" class="control-group">
<label for="id_password" class="control-label requiredField">
Password
<span class="asteriskField">*</span>
</label>
<div class="controls">
<input type="text" style="display:none;">
<input name="password" autocomplete="off" required="" id="id_password"
class="textinput textInput" type="password">
</div>
</div>
: 그래서 결과가되도록, 단지 장고 바삭한 형태를 통해 암호 전에 눈에 보이지 않는 필드 (display:none
)을 삽입하는 일반적인 트릭을 할 싶습니다 자동 완성을 방지하는 또 다른 방법이 없다면 싱싱한 형태입니까?
Firefox/Linux Mint를 사용 중입니다. 양식 태그에`= "off"를하지 입력을 '자동 완성 설정
<script type="text/javascript">
function clearPassword()
{
$('#id_password').val('');
}
window.onload = clearPassword;
</script>
시도 :) 나는 양식을 사용하여 특성을 설정 –
@mohammedqudah – tyebillion
이 attr을 추가 하시겠습니까? 코드를 검사하십시오. –