How To Set Password Show/hide Eye Button In Django Form
First, I will try to solve this problem using native HTML and jquery, but I want to solve this problem in Django form without any script. I will try this source code. My expected
Solution 1:
classCustomerLoginFrom(ModelForm):
classMeta:
model = UserLoginfields= ['user_name','password']
labels = {
"user_name": "*Username",
"password": "*Password"
}
widgets = {
"user_name": TextInput(attrs={'placeholder':'ex:test','autocomplete': 'off'}),
"password": PasswordInput(attrs={'placeholder':'********','autocomplete': 'off','data-toggle': 'password'}),
}
<input type="password" id="password" name="password" class="form-control" data-toggle="password">
Django password field to add HTML attributes directly to Django form attrs, it works for me.
Post a Comment for "How To Set Password Show/hide Eye Button In Django Form"