有木有会HTML的高手?这有道题帮我写下代码越详细越好。好吗?

写的详细的,正确我采纳并且加分

1、你好,js可以判断是否输入用户名和密码是可以的。

2、用户名密码正确错误的判断不建议写到html页面,别人查看你的源码就发现了,这个应该查询数据库中用户名和密码,判断用户输入是否正确。应该写到动态脚本中,比如asp php。

以下是我给你写的判断用户名和密码是否为空的代码。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<script>
function check(){
if (form1.users.value == ""){alert ("用户名不能为空!");document.form1.users.focus();return false;}
if (form1.password.value == ""){alert ("密码不能为空!");document.form1.password.focus();return false;}
}
</script>
</head>
<body>
<form action="?" method="post" name="form1" onsubmit="return check()">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0" style="margin:auto;margin-top:120px;">
<tr>
<TD height=60 vAlign=center width="120" align=right>用户名:</TD>
<TD align="left"> <input type="text" size="30" name="users" value=""/></TD></TR>
<TR> <TD height=40 align=right>密 ç ï¼š</TD>
<TD align="left"> <input type="password" size="30" name="password" /></TD></TR>
<TR>
<TD height=50></TD>
<TD align="left"><input type="submit" value="登 å½•" /></TD>
</TR>
</table>
</form>
</body>
</html>追问

取消写哪啊?

追答

<TD align="left"><input type="submit" value="登 录" />&nbsp;<input type="reset" value="取 消"></TD>

登录后面写上&nbsp;<input type="reset" value="取 消">

温馨提示:答案为网友推荐,仅供参考