<!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>
<form name="form1" method="post" action="">
<table width="221" border="1" cellspacing="0" cellpadding="0" bordercolor="#FFFFFF" bordercolordark="#CCCCCC" bordercolorlight="#FFFFFF">
<tr>
<td height="30" colspan="2" bgcolor="#eeeeee">.用户登录</td>
</tr>
<tr>
<td width="59" height="30">用户名</td>
<td width="162"><input name="user" type="text" id="user" /></td>
</tr>
<tr>
<td height="30">密 码:</td>
<td><input name="pwd" type="text" id="pwd" ></td>
</tr>
<tr>
<td height="30" colspan="2" align="center"><input name="Button" type="button" class="btn_grey" value="登陆" οnclick="check()" >
<input name="Submit2" type="reset" class="btn_grey" value="重置" /></td>
</tr>
</table>
</form>
<script language="javascript">
function check(){
var name=form1.user.value;
var pwd=form1.pwd.value;
if((name=="")||(name==null)){
alert("请输入用户名");
form1.user.fucus();
return;
}else if((pwd=="")||(pwd==null)){
alert("请输入密码!");
form1.pwd.focus();
return;
}else{
form1.submit();
}
}
</script>
</body>
</html>
javaScript判断用户是否输入用户名和密码
最新推荐文章于 2022-05-14 10:44:22 发布