同样的jsp代码,在加入显示或者隐藏表的某一行的之后,在chrome中点击Reset button之后没有反应,但是在IE中能正常执行验证和提交的功能。代码如下:
<%@page import="com.hp.psgit.elements.ers.cms.user.*"%>
<%@page import="com.hp.psgit.elements.ers.cms.utils.ValidationResult"%>
<%@page import="com.hp.psgit.elements.ers.cms.role.*"%>
<%@page import="java.util.*"%><%@ include file="../include/header.jsp" %>
<%@ include file="../include/menubar.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd"><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HP.com Publisher Account Management</title>
<link rel="stylesheet" type="text/css" href="/cms/style/publish.css"/>
    <script type="text/javascript" src="/cms/js/jquery-1.3.1.min.js"></script>
    <script language="javascript">
        function GoCancel(){
            document.location="/cms/reset_password";
        }
        
        function FieldValidate(){
            var wrongFormat = false;
            
            $('#f1 :input[type="text"]').each(    
                function(){
                    if($(this).val().indexOf(" ") !=-1) {
                        $('#errMsg').text("Format is wrong, please not input special character blank space in User Name ");
                        wrongFormat = true;
                    }
                    if($(this).val().length > 64){
                        $('#errMsg').text("The length of User Name field is too long, please make it less than 64 characters ");
                        wrongFormat = true;
                    }
                }
            );
            
            $('#f1 :input[type="password"]').each(    
                function(){
                    if($(this).val().indexOf(">") !=-1 ||$(this).val().indexOf("<") !=-1 ||$(this).val().indexOf(" ") !=-1) {
                        $('#errMsg').text("Format is wrong, please not input special character '<' , '>' or blank space in each password ");
                        wrongFormat = true;
                    }
                    if($(this).val().length > 64){
                        $('#errMsg').text("The length of User Name field is too long, please make it less than 64 characters ");
                        wrongFormat = true;
                    }
                }
            );            if(wrongFormat)
                return false;
                    
                var userName = document.getElementById("username").value;
                var oldPwd = document.getElementById("p1").value;
                var newPwd = document.getElementById("p2").value;
                var confirmedPwd = document.getElementById("p3").value;
                
                if(userName == null || userName == ""){
                    alert('Please input the User Name.');
                    return false;
                }
                
                if(newPwd == null || newPwd == "" || confirmedPwd == null || confirmedPwd == ""){
                    alert('Please input the new password and confirm password.');
                    return false;
                }
                if(newPwd == oldPwd){
                    alert('New password should be different with old password.');
                    return false;
                }
                
                if(newPwd != confirmedPwd){
                    alert('Please re-confirm the new password.');
                    return false;
                }
                
            document.getElementById("f1").submit();
        }        function GoSave(){
            if(document.getElementById("isSaveFlag").style.display == "none"){
                alert('Please input the old password.');
                document.getElementById("isSaveFlag").style.display ="block";
                return;
            }
            
            var oldPwd = document.getElementById("p1").value;
            
            if(oldPwd == null || oldPwd == ""){
                    alert('Please input the old password.');
                    return false;
                }
            
            FieldValidate();        }
        
        function GoReset(){
            document.getElementById("action").value = "reset";
            FieldValidate();
        }
        
    </script>
<%
    String msg = request.getAttribute("Result") == null? null : (String)request.getAttribute("Result");
    String oldPwdStyle = request.getAttribute("ResetFlag") == null? "display: block;" : "display: none;";
        if (msg != null && msg.equals("Success")){
            //session.removeAttribute("com.hp.psgit.elements.ers.cms.web.action.BaseServlet" + "USER_SESSION_KEY");
%>
<meta http-equiv="refresh" content="2;url=/cms/jsp/login.jsp"> 
<% } %>
</head>
<body bgcolor="#ffffff">
<%
    
        if (msg != null && msg.equals("Success")){
%>
                    Password was updated successfully. Will take effect on next publish.<% 
        } else {
             
%><form name="f1" id="f1" method="POST" action="/cms/reset_password">
<input type="hidden" name="action" value="update"/>    <div class="error" id="errMsg">
            <%
                ValidationResult result = request.getAttribute("Error") == null? null:(ValidationResult)request.getAttribute("Error");
                if (result != null){
                    %>
                    <%= result.getItemError()%>
                <% 
                }
             %>
    </div> 
    <br />
     <div class="block">
         VirtualSM account management
    </div>
    
    <input type="hidden" id="oldusername" name="oldusername" 
                    value="<%= request.getAttribute("HPReleaseUser") %>"/>
    
    <table bgcolor="#eeeeee" border="1" width="90%" align="center" cellpadding="10" cellspacing="0">
    <tbody>
        <tr>
            <td width="20%"><b>User Name</b></td>
            <td>
                <input type="text" maxlength="64" id="username" name="username" 
                        value="<%= request.getAttribute("HPReleaseUser") %>"/>            
            </td>
        </tr>
        <tr id="isSaveFlag" style="<%=oldPwdStyle %>">
            <td width="20%"><b>Old Password</b></td>
            <td><input type="password" maxlength="64" id="p1" name="oldpassword" value=""/></td>
        </tr>
        <tr>
            <td><b>New Password</b></td>
            <td><input type="password" maxlength="64" id="p2" name="newpassword" value=""/></td>
        </tr>
        <tr>
            <td><b>Confirm Password</b></td>
            <td><input type="password" maxlength="64" id="p3" name="confirmedPassword" value=""/></td>
        </tr>
    </tbody>
</table>
<br />
<div style="text-align: left; position: relative; left: 5%;">
    <input type="button" value="Save" onClick="GoSave();"></input>
    <%
        if (request.getAttribute("ResetFlag") != null) {
    %>
    <input type="button" value="Reset" onClick="GoReset();"></input>
    <% 
        } 
    %>
    <input type="button" value="Cancel" onClick="GoCancel();"></input>
</div>
</form>
</body>
<% } %>
</html>
<%@ include file="../include/footer.jsp" %>