Reputation: 150
I have a secure login form for my website. In the login process, I use a file called form.js
. When I enter the username and the password, it loads but doesn't direct me to the page, however everything works fine on Chrome. I get this notification (click on the link for the image):
And this is the forms.js code:
function formhash(form, password) {
// Create a new element input, this will be our hashed password field.
var p = document.createElement("input");
// Add the new element to our form.
form.appendChild(p);
p.name = "p";
p.type = "hidden";
p.value = hex_sha512(password.value);
// Make sure the plaintext password doesn't get sent.
password.value = "";
// Finally submit the form.
form.submit();
}
Any idea about this problem?
Upvotes: 2
Views: 103
Reputation: 24577
Internet Explorer won't let you change an element's type
attribute after it has been added to the DOM. You have to set this attribute before you append the node.
Also, the correct way of setting a node's attributes is by using the setAttribute()
function.
This should work:
function formhash(form, password) {
// Create a new element input, this will be our hashed password field.
var p = document.createElement("input");
p.setAttribute("name","p");
p.setAttribute("type","hidden");
p.setAttribute("value",hex_sha512(password.value));
// Add the new element to our form.
form.appendChild(p);
// Make sure the plaintext password doesn't get sent.
password.value = "";
// Finally submit the form.
form.submit();
}
Upvotes: 3