表单(穷途末路)

<!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>
</head>


<body>
<table>
<form name="login" method="post" action="login.jsp" onsubmit="return login_submit();">
    <tr>
    <td>用户名:</td>
        <td><input type="text" name="username"</td>
        
    </tr>
    <tr>
    <td>密码:</td>
    <td><input type="password" name="password"   /></td>    
    </tr>
    <tr>
    <td>&nbsp;<input type="submit" value="登录"  /></td>
    </tr>
    </form>
    




</table>
</body>
<script type="text/javascript">
 function login_submit() //登录验证函数
 {
if(document.login.username.value=="")   //如果用户名为空

alert("请输入用户名!");
document.login.username.focus(); //使密码输入框获输入得焦点
return false;

}else if(document.login.password.valus=="") //如果密码输入为空
{
alert("请输入密码!");
document.login.password.focus(); //使密码框获得输入焦点
return false;
}else
{
document.login.submit(); //提交表单
return true;
}
 }
</script>
</html>

猜你喜欢

转载自blog.csdn.net/qq_34223351/article/details/53147863