登陆界面点用户名和密码后,如果用户名为空,提示"用户名不能为空",我下面的代码怎么运行后没有反映啊?(刚学,请指教)

etilm 2006-05-15 01:59:39
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
function abc()
{
if(form1.textfield1.value=="")
{
window.alert("用户名不能为空!");
form1.textfield1.focus();
}
}
</script>
</head>
<body><form action="" method="post">
<div align="center">
<table width="255" border="0">
<tr>
<td width="69" height="39">用户名:</td>
<td width="176"><input type="text" name="textfield1"></td>
</tr>
<tr>
<td height="47">密 码:</td>
<td><input type="text" name="textfield2"></td>
</tr>
<tr>
<td height="41" colspan="2"><div align="center">
<input type="submit" name="Submit" value="提交" onClick="abc()">
<input type="reset" name="Submit" value="清空">
</div></td>
</tr>
</table>
</div>
</form>

</body>
</html>
...全文
2877 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovebeyondforever 2006-05-15
  • 打赏
  • 举报
回复
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
function abc()
{
if(form1.textfield1.value=="")
{
window.alert("用户名不能为空!");
form1.textfield1.focus();
}
}
</script>
</head>
<body><form action="" method="post" name="form1">
<div align="center">
<table width="255" border="0">
<tr>
<td width="69" height="39">用户名:</td>
<td width="176"><input type="text" name="textfield1"></td>
</tr>
<tr>
<td height="47">密 码:</td>
<td><input type="text" name="textfield2"></td>
</tr>
<tr>
<td height="41" colspan="2"><div align="center">
<input type="submit" name="Submit" value="提交" onClick="abc()">
<input type="reset" name="Submit" value="清空">
</div></td>
</tr>
</table>
</div>
</form>

</body>
</html>
samjuly 2006-05-15
  • 打赏
  • 举报
回复
<script language="javascript">
function abc()
{
if(form1.textfield1.value=="")
{
window.alert("用户名不能为空!");
form1.textfield1.focus();
}
form1.submit

}
</script>
gxh7506 2006-05-15
  • 打赏
  • 举报
回复
修改:<form action="" method="post" id="form1" onsubmit="return abc()">
abc()函数:
function abc(){
if(form1.textfield1.value==""){
window.alert("用户名不能为空!");
form1.textfield1.focus();
return false;
}
return true;
}

etilm 2006-05-15
  • 打赏
  • 举报
回复
还是没有提示啊!
laochake 2006-05-15
  • 打赏
  • 举报
回复
function abc(){
if(form1.textfield1.value==""){
window.alert("用户名不能为空!");
form1.textfield1.focus();
return false;
}
return true;
}
cqq 2006-05-15
  • 打赏
  • 举报
回复
<form action="" method="post" onsubmit="abc()">

87,995

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧