开发者

How to do validation in java script involve two jsp page?

First page's image

How to do validation in java script involve two jsp page?

Second page's image

How to do validation in java script involve two jsp page?

First page's code

<jsp:useBean id="labelBean" scope="session"
    class="my.com.infopro.ibank.ui.bean.LabelBean" />
<jsp:useBean id="txLimitMaintBean" scope="session"
    class="my.com.infopro.ibank.ui.bean.TxLimitMaintBean" />
<jsp:useBean id="lang" scope="session"
    class="my.com.infopro.ibank.ui.bean.LanguageBean" />

<%@ page import="java.util.Iterator"%>
<%@ page import="my.com.infopro.ibank.dto.TxLimitMaintDto"%>
<%@ page import="my.com.infopro.ibank.ui.bean.TxLimitMaintBean"%>

<%
    request.getSession(true);
    String contextPath = request.getContextPath();
    txLimitMaintBean.queryTxList();
    //String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>
<%
    labelBean.getLabel("TRANSACTION_LIMIT");
%>
</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">
 <jsp:include page="/ScriptHeader.jsp"/>

</head>

<body>
<form name="form" method="POST" action="" dir="<%=lang.getDir()%>">


<table width="500" border="0" align="center">
    <tr>
        <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="4">
        <p align="left" class="mainHeader"><%=labelBean.getLabel("TRANSACTION_LIMIT")%>
        </p>
        </td>
    </tr>
    <tr>
        <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="4">
        <p align="left" class="subHeader"><%=labelBean.getLabel("CURR_TRNSCT_LMT")%></p>
        </td>
    </tr>

    <tr> 
      <td colspan="3"><div align="center"> 
          <p class="statusError"> 
            <%if(request.getParameter("error") != null) out.println(labelBean.getLabel(request.getParameter("error"))); else out.println("");%>
          </p>
        </div></td>
    </tr>

    <tr>
        <td colspan="4">&nbsp;</td>
    </tr>


    <tr>
        <td colspan="4">
        <p align="left"><%=labelBean.getLabel("FILL_IN_NEWLMT")%></p>
        </td>
    </tr>
    <tr>
        <td colspan="4">
        <p align="left"><%=labelBean.getLabel("MAX_LMT")%></p>
        </td>
    </tr>
</table>

<br />


<table align="center">
    <tr class="table_header">
        <td width="130" align="left" class="tableHeader"><%=labelBean.getLabel("LIMIT")%></td>
        <td width="130" align="left" class="tableHeader"><%=labelBean.getLabel("EXISTING_LIMIT")%></td>
        <td width="130" align="right" class="tableHeader"><%=labelBean.getLabel("MAX_LIMIT")%></td>
        <td width="80" align="left" class="tableHeader"></td>
    </tr>
    <%
        for (Iterator iter = txLimitMaintBean.getTxLimitMaintList().iterator(); iter
                .hasNext();) {

            TxLimitMaintDto txLimitMaintDto = (TxLimitMaintDto) iter.next();
    %>


    <tr class="tableRowEven">
        <td><%=txLimitMaintDto.getTxType()%></td>
        <td><%=txLimitMaintDto.getTxCurrLimit()%></td>
        <td><%=txLimitMaintDto.getTxMaxLimit()%></td>
        <td><a href="<%=contextPath%>/TxLimitMaintServlet?tranx=update&typeUpdate=<%=txLimitMaintDto.getTxType()%>"><%=labelBean.getLabel("UPDATE")%></a>  </td>


    </tr>
    <%
        }
    %>


</table>

<br />
<br />



<table width="500" border="0" align="center">
    <tr>
        <td align="left" class="footer"><%=labelBean.getLabel("DISCLAIMER")%></td>
    </tr>
    <tr>
        <td align="left" class="footer">
        <ul>
            <li><%=labelBean.getLabel("TRANSFER_SUCCESS")%></li>
        </ul>
        </td>
    </tr>
</table>

<jsp:include page="/Footer.jsp" />
</form>
</body>
</html>

Second page's code

<jsp:useBean id="labelBean" scope="session"
    class="my.com.infopro.ibank.ui.bean.LabelBean" />
<jsp:useBean id="txLimitMaintBean" scope="session"
    class="my.com.infopro.ibank.ui.bean.TxLimitMaintBean" />
<jsp:useBean id="lang" scope="session"
    class="my.com.infopro.ibank.ui.bean.LanguageBean" />
<%@ page import="java.util.Iterator"%>
<%@ page import="my.com.infopro.ibank.dto.TxLimitMaintDto"%>
<%@ page import="my.com.infopro.ibank.ui.bean.TxLimitMaintBean"%>

<%
    //request.getSession(true);
    String contextPath = request.getContextPath();

    //String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>
<%
    labelBean.getLabel("TRANSACTION_LIMIT");
%>
</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">
 <jsp:include page="/ScriptHeader.jsp"/>

<script language="JavaScript">

function back() {
    document.form.action="<%=contextPath %>/TxLimitMaintServlet?tranx=start";
    document.form.submit();
}


function validateAndSubmit() {
    var msg1 = "<%=labelBean.getLabel("MSG_REQUIRED_FIELD")%>";
    var msg2 = "<%=labelBean.getLabel("MSG_CANNOT_CONTAIN_CHARACTER")%>";
    var msg3 = "<%=labelBean.getLabel("MSG_IN_THE_FIELD")%>";
    var msg4 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER")%>";
    var msg5 = "<%=labelBean.getLabel("WITH")%>";
    var msg6 = "<%=labelBean.getLabel("TO")%>";
    var msg7 = "<%=labelBean.getLabel("MSG_CHARACTER")%>";
    var msg8 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_VALID_NUMBER")%>";
    var msg9 = "<%=labelBean.getLabel("MSG_REQUIRED_FIELD")%>";
    var msg10 = "<%=labelBean.getLabel("MSG_WITH_EXACTLY")%>";
    var msg11 = "<%=labelBean.getLabel("MSG_WITH_VALID_DATE")%>";
    var msg12 = "<%=开发者_如何学JAVAlabelBean.getLabel("MSG_EXAMPLE_DATE")%>";
    var msgNum11 = "<%=labelBean.getLabel("MSG_WITH_A_MINIMUM_VALUE_OF")%>";
    var msgNum12 = "<%=labelBean.getLabel("MSG_WITH_A_MAX_VALUE_OF")%>";
    var msgNum13 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_ROUND_INETEGER")%>";
    var msgNum14 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_AT_MOST")%>";
    var msgNum15 = "<%=labelBean.getLabel("MSG_DECIMAL_PLACES")%>";

    var maxLimit = parseInt(form.maxLimit.value);   
    var newLimit = parseInt(form.txNewLimit.value);

         if (! validateNumericEntry(form.txNewLimit, "<%=labelBean.getLabel("NEW_LIMIT")%>" + " ",  true, 2, 1, <%=TxLimitMaintBean.getTotalMaxLimit()%>, msg9, msg8, msg4,
                  msgNum11, msgNum12, msgNum13, msgNum14, msgNum15))
            return false;

        if( newLimit > maxLimit){

            alert("<%=labelBean.getLabel("MSG_CANNOT_EXCEED")%>");  
            return false;
        } 

        return true;
    }



</script>


</head>

<body>
<form name="form" method="POST" action="<%=contextPath%>/TxLimitMaintServlet?tranx=confirm" onsubmit="#" dir="<%=lang.getDir()%>">


<table width="500" border="0" align="center">
    <tr>
        <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="4">
        <p align="left" class="mainHeader"><%=labelBean.getLabel("TRANSACTION_LIMIT")%>
        </p>
        </td>
    </tr>
    <tr>
        <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="4">
        <p align="left" class="subHeader"><%=labelBean.getLabel("CURR_TRNSCT_LMT")%></p>
        </td>
    </tr>
    <tr>
        <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="4">
        <p align="left"><%=labelBean.getLabel("FILL_IN_NEWLMT")%></p>
        </td>
    </tr>
    <tr>
        <td colspan="4">
        <p align="left"><%=labelBean.getLabel("MAX_LMT")%></p>
        </td>
    </tr>
</table>

<br />


<table align="center">
    <tr class="table_header">
        <td width="130" align="left" class="tableHeader"><%=labelBean.getLabel("LIMIT")%></td>
        <td width="130" align="left" class="tableHeader"><%=labelBean.getLabel("EXISTING_LIMIT")%></td>
        <td width="130" align="left" class="tableHeader"><%=labelBean.getLabel("NEW_LIMIT")%></td>
        <td width="80" align="right" class="tableHeader"><%=labelBean.getLabel("MAX_LIMIT")%></td>
    </tr>



    <tr class="tableRowEven">
        <td><%=txLimitMaintBean.getTxType()%></td>
        <td><input name="txCurrLimit" + type="text"
            value="<%=txLimitMaintBean.getTxCurrLimit()%>" readonly="readonly"></td>
        <td><input name="txNewLimit" type="text"></td>
        <td><%=txLimitMaintBean.getTxMaxLimit()%></td>
        <td><input name="maxLimit" value="<%=txLimitMaintBean.getTxMaxLimit()%>" type="hidden"></input></td>

    </tr>



</table>

<br />

<table align="center">
    <tr>
        <td align="right"><input type="button" class="button" value="Back" onclick="back();"></td>
        <td align="right"><input type="reset" class="button"
            value="Reset"></td>
        <td align="left"><input type="submit" class="button" value="Next"
            onClick="return validateAndSubmit();"></td>
    </tr>
</table>
<br />






<table width="500" border="0" align="center">
    <tr>
        <td align="left" class="footer"><%=labelBean.getLabel("DISCLAIMER")%></td>
    </tr>
    <tr>
        <td align="left" class="footer">
        <ul>
            <li><%=labelBean.getLabel("TRANSFER_SUCCESS")%></li>
        </ul>
        </td>
    </tr>
</table>

<jsp:include page="/Footer.jsp" />
</form>
</body>
</html>

The problem is: how can I validate add up of both 3rd Party Transfer and Bill Payment can not exceed 10,000?


you wouldn't be able to javascript to get the values from the previous page. any reason why you can't access them from the session to compute? remember that if you want to use javascript to calculate the totals, you'll need to render the other value(s) on the page (you could use a hidden input so it doesn't show up).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜