为什么不提示用户名为空呢?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language=JavaScript>
function check()
{
if(document.forml.yfm.value=="")
{
alert("用户名不能为空");
return false;
}
if(document.forml.mm.value=="")
{
alert("密码不能为空");
return false;
}
}
</script>
</head>
<body><form name="form1" method="post" action=""onsubmit="javascript:return check();">
<div align="center">
<table width="283" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="25" colspan="3" valign="top"><input type="text" name="yfm"></td>
</tr>
<tr>
<td height="25" colspan="3" valign="top"><input type="text" name="mm"></td>
</tr>
<tr>
<td width="66" height="19"> </td>
<td width="95" valign="top">
<input type="submit" name="Submit" value="提交">
</td>
<td width="122"> </td>
</tr>
</table>
</div></form>
</body>
</html>
这代码错在那里呢?
参考答案:<form name="form1" method="post" action=""onsubmit="javascript:return check();">
不该省的空格不能省,:<form name="form1" method="post" action="" onsubmit="return check()">
不该多的不要多(onsubmit="return check()")
最后,也是最关键的:
把document.forml里面的l(L)换成1呀!