Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. class ChangePasswordForm(forms.Form):
  2.     password1 = forms.CharField(label='New Password',widget=forms.PasswordInput())
  3.     password2 = forms.CharField(label='Confirm Password',widget=forms.PasswordInput())
  4.  
  5.     def clean_password1(self):
  6.         password1 = self.cleaned_data.get("password1")
  7.         return password1
  8.        
  9.     def clean_passwords(self):
  10.         password1 = self.cleaned_data.get("password1")
  11.         password2 = self.cleaned_data.get("password2")
  12.         if password1 != password2:
  13.             raise forms.ValidationError('The passwords do not match.')
  14.         elif password1 == "" or password2 == "":
  15.             raise forms.ValidationError('Neither of the Fields can be blank!')
  16.         elif password1 == "changeme" or password2 == "changeme":
  17.             raise forms.ValidationError('You cannot use that password!')
  18.         else:
  19.             return password2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement