我有这个javascript代码。但是代码没有得到输入的值,我在这里做错了什么?
<script type="text/javascript">
function myFunc() {
"use strict";
var un = document.getElementByID('user').value;
var pw = document.getElementByID('pass').value;
var x ;
if(un=="abc") {
if(pw=="123") {
document.getElementById('validate').innerHTML ="validation sucessful";
}
else {
document.getElementById('validate').innerHTML ="validation unsuccessful";
}
}
else {
document.getElementById('validate').innerHTML ="invalid username";
}
}
</script>
<p>Click on the button to login</p>
USERNAME : <input type='text' id='user' value=" " /><!-- Should be like type="text" and not type=" text"-->
PASSWORD: <input type='password' id='pass' /> <!-- Should be like type="password" and not type=" password"-->
<p id='validate'></p>
<input type='button' onclick="myFunc()" value='Login' />