Django password fields placeholder

前端 未结 3 2002
不知归路
不知归路 2020-12-11 10:51

I try to enable placeholder at my SignUp form with 4 fields: phone, email, password1, password2. For first two fields all correct, but for password field it doesn\'t work.

3条回答
  •  自闭症患者
    2020-12-11 11:21

    This code works fine

    class SignUpForm(UserCreationForm):    
        password1 = forms.CharField(max_length=16, widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Password from numbers and letters of the Latin alphabet'}))
        password2 = forms.CharField(max_length=16, widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Password confirm'}))
        class Meta:
            model = User
            fields = ('phone', 'email', 'password1', 'password2', 'is_client','is_partner')
            widgets = {
                'email': EmailInput(attrs={'class': 'form-control', 'placeholder': 'Email adress'}),
                'phone': TextInput(attrs={'class': 'form-control', 'placeholder': 'Phone number format +79011234567'}),
    
    
            }
    

提交回复
热议问题