Reputation: 3
The variable ocode does not get passed to the def resetusername. document.getElementById("ocode").value gets the value from storageName and I verified it by using 'alert' function. Can anyone please tell me what I am doing wrong.Thank you
function mySubmit() {
document.getElementById("ocode").value =
localStorage.getItem("storageName");
alert(document.getElementById("ocode").value);
document.getElementById("myform").action = "/postresetusername/";
}
<form method="post" id="myform" onsubmit="mySubmit()">
{% csrf_token %}
<div class = "login-box">
<h1>Reset Username</h1>
<div class = "textbox" style="float:left">
<input type = "email" placeholder="Previous Email" name = "email" id="email">
</div>
<input type='hidden' id= "ocode" name='id' value="">
def postresetusername(request):
email = request.POST.get('email')
ocode = request.POST.get('ocode')
authe.verify_password_reset_code(ocode, "new_pwd")
return render(request, "signIn2.html", {"messg": "Password reset"})
return render(request, "signIn2.html", {"messg": "Cant reset"})
Upvotes: 0
Views: 27
Reputation: 207527
Forms inputs use the name and you are using the id.
<input type='hidden' id= "ocode" name='id' value="">
^^^^^^^^^
and the backend is using
ocode = request.POST.get('ocode')
^^^^^
Upvotes: 1