Struts2極速表單驗證架構

來源:互聯網
上載者:User

 Struts2_極速表單驗證架構使用說明書.pdf

 

1 .包

struts2quickvalidationplugin1.0.jarWebWEBINF/lib;
2.配置

 src/struts.xml package quickValidation;:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
  <package name="test" namespace="" extends="quickValidation">
   <action name="helloworld" class="actions.HelloWorldAction">
    <result name="index">/index.jsp</result>
    <result name="success">/helloworld.jsp</result>
   </action>
  </package>
 
</struts>

 

3.register.jsp中的部份代碼

<!-- RapidValidation 表單驗證架構開始 -->
 <style type="text/css">
/** 修改驗證架構提示文字位置和顏色為同行顯示, 字型為藍色 */
.validation-advice {
 display: inline;
 /* color: blue; */
}
</style>

 <script src="<%=path%>/rapid_validation/prototype_for_validation.js" type="text/javascript"></script>
 <script src="<%=path%>/rapid_validation/validation_cn.js" type="text/javascript"></script>
 <script src="<%=path%>/rapid_validation/effects.js"  type="text/javascript"></script>
 <link rel="stylesheet" type="text/css" href="<%=path%>/rapid_validation/style_min.css" />
 <script src="<%=path%>/prototype-1.4.0.js" type="text/javascript"/>
 <script src="<%=path%>/json.js" type="text/javascript"/>
 <!-- RapidValidation  表單驗證架構結束 -->

<s:form action="register.action" onsubmit="return before();"
        cssClass='required-validate'>
        <table width="100%" border="0" cellspacing="0" cellpadding="0"
         id="regedit_tab">
         <tr>
          <td width="10%" height="40" align="right" class="style3">
           使用者名稱:
           <span class="STYLE5">*</span>&nbsp;
          </td>
          <td colspan="3" valign="middle">
           <s:textfield name="user.userName" label="使用者名稱"
            value="${param['user.userName']}" required="true"
            onblur="validateName();"
            cssClass="required min-length-6 max-length-20 validate-alphanum" />
          <span id="tip" style="color: red; font-weight: bold"></span>
          </td>
          <td width="40%" class="style4">
           使用者名稱長度為6-20位字元,建議你用手機號碼或郵箱註冊, 避免使用者名稱重複,而且方便記憶哦!
          </td>
         </tr>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.