当前位置:编程学习 > JSP >>

jsp onclick 没起作用

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP '2.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> </head> <script language="javascript"> function check(){ String userInputPassword=null; String userInputName=document.getElenmentsByName("name"); System.out.println("d"); if(document.form1.name.value=""){ alert("姓名不能为空"); reture false; } if(document.form1.password.value==""){ alert("密码不能为空"); reture false; } } </script> <body> <form name="form1" action="check.jsp" method="post"> 用户名<input type="text" name="name"/> 密  码<input type="password" name="password"/> <input type="submit" value="提交" onClick="return check();" /> <input type="reset" value="重置"/> </form> </body> </html>
答案:JS 名字起的不对,可能是内置对象,所以起check()时,改成fcheck()等。。就不会调用不到了。。
其他:你可以把move函数改为:
function move(){
alert("move被调用了");
} 
就可以测试出onClick或onSubmit事件是否起作用了,我测试了一下前面两个事件都能被触发。我看原因在于你原来的move函数:
document.newinfo.information.value=document.newinfo.end_month.value
document下的这个newinfo自定义对象有问题
 

上一个:在家做JSP图书管理系统 代码和调试都好了 我该怎么把它教给老师 导入的图片会因换电脑问题图片显示不了吗
下一个:JSP、SQL Server环境下编码关于rs的问题,怎么也看不明白

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,