The problem is that I can't get value of my password fields - alert with pso1 returns null.
I don't see any error in this code so I'm asking for help.
<form class='container' onsubmit="return checkit()">
<h1> Javascript </h1>
Login <input type='text' id='log'><br>
Password <input type='password' id='pso1'><br>
Confirm passwordd <input type='password' id='pso2'><br>
<button>Register</button>
</form>
<script type="text/javascript">
var pso1=document.getElementById('pso1').value ;
var pso2=document.getElementById('pso2').value ;
alert(pso1);
function checkit(){
if(pso1=!pso2){
return false;
alert('Passwords are not the same.');
}
else{
return true;
alert('work');
}
}
</script>
</body>
alert()afterreturnwon't work.returnleaves the function and nothing after that executes.