1. 程式人生 > >註冊兩次密碼的驗證

註冊兩次密碼的驗證

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())
密碼驗證

註冊兩次密碼的驗證