javascript - Submit calls function two times -
when submit form enter, works without problems. can log in. when submit form button, logs in on firefox, not on chrome. problem is, repeats function twice , sends different hashed password. how can make work on chrome too?
button:
<div id="submit" name="submit" value="login" class="ui fluid large pink submit button" onclick="submitform();">login</div>
form:
<form id="form" autocomplete="off" class="ui large form" id = "form" name="form" method="post" action="php/verify.php" onsubmit="submitform();">
i added onsubmit="submitform();"
form, call function when submit form enter
.
javascript function:
function submitform(){ var form = document.getelementbyid("form"); var pwd = document.getelementbyid('pwd'); var hash = new jssha("sha-256", "text", {numrounds: 1}); hash.update(pwd.value); var hash = hash.gethash("hex"); var password = document.createelement("input"); password.name="password"; password.type="hidden"; password.id = "password"; password.value = hash; alert(password.value); form.appendchild(password); form.submit(); pwd.value = ""; }
in onsubmit handler, you're submitting form:
form.submit();
if that, handler has return false, means need
<form ... onsubmit="submitform(); return false;">
otherwise submit form manually, browser submit second time, since onsubmit didn't return false;
Comments
Post a Comment