码迷,mamicode.com
首页 > Web开发 > 详细

提交验证是否为空-js代码

时间:2014-07-23 22:27:47      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   io   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function check(){
    var name2=document.formname.name1;
    var password2=document.formname.password1;
    if(name2.value==""){
        alert("用户名不能为空");
        name2.focus();
        return false;
    }
    if(password2.value==""){
        alert("密码不能为空")
        password2.focus();
        return false;
    }
}
</script>
</head>

<body>
<form action="5秒后跳转.html" name="formname" method="get" onsubmit="return check()">
用户名:<input type="text" name="name1"  /><br />
密码:<input type="password" name="password1"  /><br />
<input type="submit" name="提交1" value="提交" />
</form>
</body>
</html>

提交验证是否为空-js代码,布布扣,bubuko.com

提交验证是否为空-js代码

标签:style   blog   http   java   color   io   

原文地址:http://www.cnblogs.com/yunmengxiaohe/p/3864067.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!