<!-- 验证账号密码不为空 -->
<form action="https://how2j.cn/study/login.jsp" method = "post" onsubmit="return login()" >
账号:<input id="d1" type="text" name="name"> <br/>
密码:<input id = "d2" type="password" name="password" > <br/>
<input type="submit" value="登陆">
</form>
<script>
function login(){
var div1 = document.getElementById("d1");
var div2 = document.getElementById("d2");
if(div1.value.length == 0){
alert("用户名不能为空!");
return false;
}
if(div2.value.length == 0){
alert("密码不能为空!");
return false;
}
return true;
}
</script>