form表单提交前验证

<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>

?

上一篇:IDEA将maven项目打包时同时带上项目的maven依赖(转)


下一篇:systemd 介绍