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>
</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>