首页 > 其他 > 详细

form表单提交前验证

时间:2021-07-24 00:01:42      阅读:17      评论:0      收藏:0      [点我收藏+]
<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>

?

form表单提交前验证

原文:https://blog.51cto.com/u_15297803/3175958

(0)
(0)
   
举报
评论 一句话评论(0
分享档案
最新文章
教程昨日排行
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!