<form action="" method="post" id="login-form" onsubmit="return toVaild()">
<input class="form-control" id="id_account" name="account" type="text" placeholder="账号"/>
<input class="form-control" id="id_password" name="password" type="password" placeholder="密码">
<form>
<script type="text/javascript">
document.getElementById(‘id_account‘).focus()
function toVaild() {
var account = document.getElementById("id_account").value;
var password = document.getElementById("id_password").value;
if (account == "" || password == "") {
alert("请输入账号和密码");
return false;
} else {
return true;
}
}
</script>
?