诸位。。麻烦帮我看看。。我对了半天没找到问题出在哪里。我用dreamweaver画的jsp页面都无法调用js。直接就跳上action了。每个页面都是我眼睛花了。高分,,高分求解脱<%@ page language="java" 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>
<style>
#userName{width:150px}
#userPass{width:150px}
#validateCode{width:150px}
</style> <head>
<base href="<%=basePath%>">
<title>用户登录</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">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<script type="text/javascript">
function checkLogin(){
var userName=document.getElementById("userName").value;
var userPass=document.getElementById("userPass").value;
if(userName==""){
alert("帐号必填!");
return false;
}else if(userPass==""){
alert("密码必填!");
return false;
}else{
return true;
}} </script>
<body>
<center>
<br />
<div align="center" ><h1><font color="#9999FF">用户登录</font></h1></div>
<br />
<hr align="center" />
<br /> <form action="user-login" method="post">
<table border="0" height="100">
<tr>
<td>${notice}</td>
</tr>
<tr align="left" bgcolor="#9999FF" >
<td>用户名:<input type="text" name="user.userName"></td>
</tr>
<tr align="left" bgcolor="#9999FF">
<td>密 码 :<input type="password" name="user.userPass"></td>
</tr>
<tr align="left" bgcolor="#9999FF">
<td>验证码:<input type="text" name="validateCode"/></td>
</tr>
<tr align="left" bgcolor="#9999FF">
<td>
<img id="codeImg" src="validateCode-getCode" alt="点我就变!"
onClick="javascript:window.location.reload()">
看不清?点图片
</td>
</tr>
<tr align="center" bgcolor="#9999FF">
<td colspan="2" align="center">
<input type="submit" value="登录" onclick="return checkLogin()">
<input type="reset" value="重置"/>
<a href="<%=basePath%>jsp/updPass1.jsp">忘记密码?</a>
</tr>
</table>
</form>
</center>
</body>
</html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<style>
#userName{width:150px}
#userPass{width:150px}
#validateCode{width:150px}
</style> <head>
<base href="<%=basePath%>">
<title>用户登录</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">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<script type="text/javascript">
function checkLogin(){
var userName=document.getElementById("userName").value;
var userPass=document.getElementById("userPass").value;
if(userName==""){
alert("帐号必填!");
return false;
}else if(userPass==""){
alert("密码必填!");
return false;
}else{
return true;
}} </script>
<body>
<center>
<br />
<div align="center" ><h1><font color="#9999FF">用户登录</font></h1></div>
<br />
<hr align="center" />
<br /> <form action="user-login" method="post">
<table border="0" height="100">
<tr>
<td>${notice}</td>
</tr>
<tr align="left" bgcolor="#9999FF" >
<td>用户名:<input type="text" name="user.userName"></td>
</tr>
<tr align="left" bgcolor="#9999FF">
<td>密 码 :<input type="password" name="user.userPass"></td>
</tr>
<tr align="left" bgcolor="#9999FF">
<td>验证码:<input type="text" name="validateCode"/></td>
</tr>
<tr align="left" bgcolor="#9999FF">
<td>
<img id="codeImg" src="validateCode-getCode" alt="点我就变!"
onClick="javascript:window.location.reload()">
看不清?点图片
</td>
</tr>
<tr align="center" bgcolor="#9999FF">
<td colspan="2" align="center">
<input type="submit" value="登录" onclick="return checkLogin()">
<input type="reset" value="重置"/>
<a href="<%=basePath%>jsp/updPass1.jsp">忘记密码?</a>
</tr>
</table>
</form>
</center>
</body>
</html>
解决方案 »
- 如何将Tomact与域名绑定,通过域名访问本地服务器上自己开发的J2EE项目(域名访问jsp)
- 正则如何进行混合计算?急》》》》》
- !!!上火啊,FCKeditor2.6上传文件的配置问题,整了好几天了
- 使用lucene建立索引的问题
- 高分求助转码问题
- 日期比較oracle
- 困扰了2天的jpa问题,求高手解答
- 各位大神,有谁用过58的gaea
- 请问各位大虾:能否在JSplitPane上加Component呢
- 有谁能讲讲数据库中预编译语句有什么意义,并且在java中使用有什么意义
- spring MVC中的声明式事务的管理问题
- 在jsp页面中直接打开本地文件夹,效果就像在操作系统中打开一个文件夹一样。
但是在你的input中,只有name是userName,根本没有ID,肯定找不到。
password与userName一样,修改一下就好了!
你判断的是userName=="",这不安全,如果数据一个空格,你的判断形同虚设。还有,不要使用<input type="submit">在IE下没有问题,如果在火狐下面,即使JS判断了,也会直接提交的,你这样写.....条件判断
如果都成立
$('form1').action=提交路径;
$('form1').submit();这里的form1可以随便起,就是在form中加上一个name属性
跟你的name="user.userName" 意思一样。