
2008-6-16 23:53
TonnySun
javascript有效性检查
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>测试JavaScript </title>
</head>
<script language="JavaScript">
function check()
{
alter("DDDDDDDDD");
if(document.form1.user.value="")
{
alter("用户名不能为空");
return;
}
}
</script>
<body>
<form action="test.jsp" name="form1" method="post" onClick="check()">
<table>
<tr>
<td>用户名 </td>
<td>
<input type="text" name="user">
</td>
</tr>
<tr>
<td>密 码 </td>
<td>
<input type="password" name="pw">
</td>
</tr>
<tr>
<td colspan="2">
<p align="center">
<input type="submit" name="ok" value="提交">
<input type="reset" name="cancel" value="重置">
</p>
</td>
</tr>
</table>
</form>
</body>
</html>
请问这段代码为何不执行输入框的有效性检查?另我在不同的机器上上述代码还会报对象不可用或错误的警告框,应该是JavaScript函数的if判断语句那边,请指教,谢谢!
2008-6-17 08:48
developerm
<form action="test.jsp" name="form1" method="post" onClick="check()">
onsubmit="check()"
2008-6-17 09:14
iooyoo
form的onclick。。。
2008-6-17 17:57
javalod
js建议单独弄个文件
*** 作者被禁止或删除 内容自动屏蔽 ***
2008-6-26 17:08
ericlntm
就算交验成功估计也有问题,方法中的返回值都没有写
2008-6-28 11:30
Sky-Tiger
校验过程一般是客户端和服务器端都做!这样才更安全!
一般客户端仅仅最简单的格式验证就可以了!
2008-6-28 14:47
justforregister
用个javascript的ide吧, 不要手写
2008-6-28 18:15
Sky-Tiger
[quote]原帖由 [i]justforregister[/i] 于 2008-6-28 14:47 发表 [url=http://www.itpub.net/redirect.php?goto=findpost&pid=10796606&ptid=1006930][img]http://www.itpub.net/images/common/back.gif[/img][/url]
用个javascript的ide吧, 不要手写 [/quote]
;)
啥IDE?
2008-6-28 18:25
justforregister
太多了, 譬如aptana
2008-6-28 19:50
Sky-Tiger
说详细点行不?
2008-6-28 21:32
justforregister
[quote]原帖由 [i]Sky-Tiger[/i] 于 2008-6-28 19:50 发表 [url=http://www.itpub.net/redirect.php?goto=findpost&pid=10798285&ptid=1006930][img]http://www.itpub.net/images/common/back.gif[/img][/url]
说详细点行不? [/quote]
你狠:mad:
2008-7-3 12:13
laobai1982
这个帖子杂了?!有脚本错误?!
2008-7-3 13:03
justforregister
应该是的
页:
[1]

Powered by ITPUB论坛