i have a really simple login script on a website, it uses just 1 simple password, and it does just fine what i need from it. thing is, it only works when clicking the "LOGIN" word. what i need it to do is to also work when pressing the Enter key. here´s the code:
<div style="background-image:url(images/IMG_Log_In_teste.jpg);width:1490px;height:243px;color:black;font-size:20px;" >
<br></br>
<a href="areaclienteOLD.html" onclick="javascript:return validatePass()">
<div class="cities">
<font color="white">
LOGIN
</font>
</div>
</a><br></br>
<input id='PASSWORD' type='PASSWORD' />
<a href="areaclienteOLD.html" onclick="javascript:return validatePass()"></a><br></br>
<script>
function validatePass(){
if(document.getElementById('PASSWORD').value == 'pkmass1725'){
return true;
}else{
alert('Password errada! Tente de novo.');
return false;
}
}
</script>
</div>
i already tried adding input types and other things but nothing makes it work :(
UPDATE:
meanwhile i changed the code to this:
<div style="background:blue;width:1490px;height:243px;color:black;font-size:20px;" >
<a href="areaclienteOLD.html" onclick="javascript:return validatePass()">
<div class="cities">
<font color="white">
LOGIN
</font>
</div>
</a>
<input id='PASSWORD' type='PASSWORD' onkeydown="javascript:return validatePass()"/>
<a href="areaclienteOLD.html" onclick="javascript:return validatePass()"></a>
<script>
function validatePass(){
if(document.getElementById('PASSWORD').value == 'pkmass1725'){
return true;
}else{
alert('Password errada! Tente de novo.');
return false;
}
}
</script>
<script>
document.body.onkeydown = function(e) {
if (e.keyCode == 13)
validatePass();
};
</script>
</div>
but now whatever key is pressed it performs validation, so its not even possible to enter the password... i´m still missing something here