我自己定义了一个Servlet:
MyServlet extends HttpServlet,其中最后用request.getRequestDispatcher("my.jsp").forward(request, response);转向了my.jsp页面,而在my.jsp中写了表单:<form action="AnotherServlet" onsubmit="return validate()"></form>,我想用javascript来验证表单中填写的内容,而此页面中写的javascript函数function validate(),无论如何都得不到调用,请各位说说是什么原因??????同样的如果是用户直接在浏览器地址栏中输入一个jsp地址来请求的话,就可以在jsp页面中来做javascript的验证。为什木??????
MyServlet extends HttpServlet,其中最后用request.getRequestDispatcher("my.jsp").forward(request, response);转向了my.jsp页面,而在my.jsp中写了表单:<form action="AnotherServlet" onsubmit="return validate()"></form>,我想用javascript来验证表单中填写的内容,而此页面中写的javascript函数function validate(),无论如何都得不到调用,请各位说说是什么原因??????同样的如果是用户直接在浏览器地址栏中输入一个jsp地址来请求的话,就可以在jsp页面中来做javascript的验证。为什木??????
return false 才会不提交,否则直接就提交页面了,看以没反应