IE not accepting JS code BUT FF,Google Chrome and Safari is Happy with same JS code

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="sha512.js"></script>
<script type="text/javascript">
function formhash(form, password) {
	
   // Create a new element input, this will be out 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();

}
</script>
<?php
if(isset($_GET['error'])) {
   echo 'Error Logging In!';
}
?>

</head>

<body><form action="process_login.php" method="post" name="login_form">
   Email: <input type="text" name="email" /><br />
   Password: <input type="password" name="password" id="password"/><br />
   <input type="button" value="Login" onclick="formhash(this.form, this.form.password);" />
</form>
</body>
</html>

What is wrong in this code…?:rolleyes::confused:

I’m really surprised the other browsers worked. form.submit and form.appendChild are not valid. As the name of your form is login_form.
I’d try login_form.appendChild(p) and login_form.submit();

I think the problem is that IE doesn’t let you set an input element’s type after the element has been created.

Give this a try:

   // Create a new element input, this will be out hashed password field.
   try {
    // try the IE way
    var p = document.createElement('<input type="hidden">');
   } catch (e) {
    // try the conventional way
    var p = document.createElement('input');
    p.type = "hidden";
   }

Inside the formhash function, “form” is a variable, which would hold a reference to a form object.

Interesting, good to know.