0

我有一个page.jsp,它包含三个字段:旧密码、新密码和确认密码。我有一个 JavaScript 来检查确认密码和新密码是否相同。当我在 Eclipse 中测试它时,它可以按要求工作,所以我将它部署在Tomcat / webapps中。但是当我运行它时,它不会检查新密码和确认密码字段。

请告诉我该怎么做?


我的网络应用程序的屏幕截图:

源代码:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
html, body, div, h1, h2, h3, h4, h5, h6, p, img, dl,
  dt, dd, ol, ul, li, table, tr, td, form, object, embed,
  article, aside, command, details, fieldset,
  figcaption, figure, footer, group, header, hgroup, legend
 {
  margin: 0;
  padding: 0;
  border: 0;
  }
html {
  font: 82.5% verdana, helvetica, sans-serif;
  background: #fff;
  color: #333;
  line-height: 1;
  direction: ltr;
  }
  html, body {
  position: absolute;
  height: 100%;
  min-width: 100%;
  } 

  table {
  border-collapse: collapse;
  border-spacing: 0;
  }



  .button {
  min-width: 46px;
  text-align: center;
  color: #444;
  font-size: 11px;
  font-weight: bold;
  height: 27px;
  padding: 0 8px;
  line-height: 27px;
  border-radius: 2px;
  transition: all 0.218s;
  border: 1px solid #dcdcdc;
  background-color: #f5f5f5;
  cursor: default;
  }

  *+html .button {
  min-width: 70px;
  }
  button.button,
  input[type=submit].button {
  height: f1f1f1px;
  line-height: 29px;
  vertical-align: bottom;
  margin: 0;
  }

  .button:hover {
  border: 1px solid #c6c6c6;
  color: #333;
  text-decoration: none;
  transition: all 0.0s;
  background-color: #f8f8f8;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  }
  .button:active {
  background-color: #f6f6f6;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  }
  .button:visited {
  color: #666;
  }  
   .button-submit {
  border: 1px solid #3079ed;
  color: #fff;
  text-shadow: 0 1px rgba(0,0,0,0.1);
  background-color: #4d90fe;
  }
  .button-submit:hover {
  border: 1px solid #2f5bb7;
  color: #fff;
  text-shadow: 0 1px rgba(0,0,0,0.3);
  background-color: #357ae8;
  }
  button-submit:active {
  background-color: #357ae8;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
  }

  .footer-bar {
  bottom: 0;
  height: 35px;
  width: 100%;
  overflow: hidden;
  }
  .content {
  padding: 0 44px;
  }

  .table{
    padding: 0 55px
  }
.header
  {
  padding: 10px 20px 5px;
  background:#00AAFF;
  border: 1px solid #e5e5e5;
  height:20px;
  }
</style>
<script type="text/javascript">
function ccheck()
{

newPsw=document.f1.newPsw.value;

old=document.f1.old.value;
confirm=document.f1.confirm.value;

if(old=="" || old==null)
{
alert("Plz. Enter Your old password");
document.f1.old.focus();
return false;
}
if(confirm=="" || confirm==null)
{
alert("Plz. Enter Your confirm Password");
document.f1.confirm.focus();
return false;
}
i
if(newPsw=="" || newPsw==null )
{
alert("Plz. Enter Your new password");
document.f1.newPsw.focus();
return false;

}
if(newPsw!=confirm)
    {
    alert("new password and confirm does not match");
    document.f1.newPsw.focus();
    return false;

    }

return true;
}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="">
<form name="f1" id="f1" action="checkPassword.jsp" onsubmit="return ccheck()">
        <div align="center" style="padding-top: 30px">
            <table  cellspacing="10" cellpadding="10">
                <tr>
                    <td width="200" height="30"><h5>Old Password</h5></td>
                    <td  height="30"><input name="old" type="password"></td>
                </tr>
                <tr>
                    <td  height="30"><h5>New Password</h5></td>
                    <td  height="30"><input name="newPsw" type="password"></td>
                </tr>
                <tr>
                    <td height="30"><h5>Confirm Password</h5></td>
                    <td  height="30"><input name="confirm" type="password"></td>
                </tr>
            </table>
        </div>
        <div class="footer-bar"  align="center" style="padding-top: 30px">
            <table align="center" >
                <tr >
                    <td width="100" align="center"><input type="submit" class="button button-submit" value="Submit"  /></td>
                    <td width="100" align="center"><input type="reset" class="button button-submit" value="Reset" /></td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
4

1 回答 1

0

在你的问题中,我看到...

if(confirm=="" || confirm==null)
{
  alert("Plz. Enter Your confirm Password");
  document.f1.confirm.focus();
  return false;
}
i
if(newPsw=="" || newPsw==null )
{

这额外i是一个问题,并且可能导致 jsp 失败。我只是不明白为什么它会在 Eclipse 中工作。

旁注:完成此工作后,最好将样式部分分解为 .css 文件。

于 2013-04-03T06:43:39.903 回答