註冊兩次密碼的驗證
阿新 • • 發佈:2019-04-01
orm onerror 圖片 display clas self error alt 驗證
def clean(self):#驗證兩次密碼是否一致 pwd=self.cleaned_data.get(‘pwd‘) print(pwd) pwd_confirm=self.cleaned_data.get(‘pwd_confirm‘) print(pwd_confirm) if pwd==pwd_confirm: return self.cleaned_data else: raise ValidationError(‘密碼驗證兩次輸入的密碼不一致‘) def register(request): if request.method==‘GET‘: obj=F1form() return render(request,‘register.html‘,locals()) else: obj=F1form(request.POST) if obj.is_valid(): print(obj.cleaned_data) return redirect(‘/‘) else: print(obj.errors) return render(request,‘register.html‘,locals())
註冊兩次密碼的驗證