日期:2014-05-17  浏览次数:20908 次

jsp如何让submit不提交
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script language="javascript">
function psword(form){
if (form.password.value!=form.passwordagain.value);
alert("密码不一致,请重新输入!");
}
</script>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>登录成功</title>

  </head>
  
<body>
    登录成功,欢迎您&nbsp;&nbsp;<%=request.getAttribute("username") %> <br>
    <form name="add" action="user.action" method="post">
    <s:iterator value="deplist" var="dp">
<p>
    <label>员工姓名
    <input type="text" name="username" value=<%=request.getAttribute("username") %>>
    </label>
</p>
    <p>
      <label>登录密码
      <input name="password" type="password" maxlength="8">
      </label>
</p>
    <p>
      <label>确认密码
      <input name="passwordagain" type="password" maxlength="8" onchange="psword(add)">
      </label>
</p>
    <p>
      <label>性&nbsp;&nbsp;&nbsp;&nbsp;别
      <input type="text" name="sex" value=<%=request.getAttribute("sex") %>>
      </label>
</p>
    <p>
      <label>部&nbsp;&nbsp;&nbsp;&nbsp;门
      <input type="text" name="dep" value=<%=request.getAttribute("dep") %>>
      </label>
</p>
    <p>
      <label>职&nbsp;&nbsp;&nbsp;&nbsp;务
      <input type="text" name="deppo" value=<%=request.getAttribute("deppo") %>>
      </label>
</p>
    <p>
      <label>电&nbsp;&nbsp;&nbsp;&nbsp;话
      <input name="tel" type="text" maxlength="11" value=<%=request.getAttribute("tel") %>>
      </label>
</p>
</s:iterator>
<input type="submit" value="确定" onclick="psword(add)"/>&nbsp;&nbsp;<input type="reset" value="返回">
</form>
</body>
</html>

我点提交它提示了  但是还是给提交了  能不能提示不提交 

能不能根据我的代码写 谢谢