1.html源码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta http-equiv="Content-Language" content="zh-cn"> <title>JavaScript Validation Framework</title> <link rel="stylesheet" type="text/css" href="style.css"> <script language="JavaScript" src="validation-framework.js"></script> <SCRIPT LANGUAGE="JavaScript" src="site.js"></SCRIPT> </head> <body> <br /> <table cellpadding="10" width="760" cellspacing="0" align="center" class="ContentTable"> <tr> <td class="Nav" valign="top"> <br /> </td> <td valign="top"> <script language="JavaScript" src="validation-framework.js"></script> <div id="error" style="color:red;font-weight:bold"></div> <form id="form2" name="form2" method="post" action="/webproject2/servlet/survey" onsubmit="return doValidate(this)"> <table width="408" border="0"> <tr> <th width="135" align="left" scope="col">姓名:</th> <th width="257" align="left" scope="col"><label> <input name="name" type="text" id="name" size="20" /> </label></th> </tr> <tr> <th align="left" scope="row">E_mail地址:</th> <td align="left"><input name="email" type="text" id="email" size="40" /></td> </tr> <tr> <th height="26" align="left" scope="row">年龄: </th> <td align="left"><label> <input type="radio" name="age" id="radio" value="18" /> 小于18 <input name="age" type="radio" id="radio2" value="18-40" checked="checked" /> 18-40 <input type="radio" name="age" id="radio3" value="40" /> 40以上 </label></td> </tr> <tr> <th align="left" scope="row">编程时间:</th> <td align="left"><label> <select name="code" id="code"> <option value="never">不编程</option> <option value="6" selected="selected">小于6个月</option> <option value="6-12">6个月到12个月</option> <option value="12-24">12-24个月</option> <option value="24">大于24个月</option> </select> </label></td> </tr> <tr> <th align="left" scope="row">熟悉操作系统:</th> <td align="left"><label> <select name="os" size="4" multiple="multiple" id="os"> <option value="WinXP" selected="selected">WinXP</option> <option value="Win2000/2003">Win2000/2003</option> <option value="Mac OS">Mac OS</option> <option value="Linux">Linux</option> </select> </label></td> </tr> <tr> <th height="23" align="left" scope="row">编程语言:</th> <td align="left"><label> <input name="language" type="checkbox" id="language" value="Java" /> Java <input name="language" type="checkbox" id="language" value="C" /> C <input name="language" type="checkbox" id="language" value="C++" /> C++ <input name="language" type="checkbox" id="language" value="C#" /> C# <input name="language" type="checkbox" id="language" value="VB" /> VB</label></td> </tr> <tr> <th align="left" scope="row">建议:</th> <td align="left"><label> <textarea name="comment" cols="40" rows="5" id="comment"></textarea> </label></td> </tr> <tr> <th align="left" scope="row"><label> <input type="submit" name="submit" id="submit" value="提交" /> </label></th> <td align="left"><label> <input type="reset" name="reset" id="reset" value="重置" /> </label></td> </tr> </table> </form> </body> </html>
?
2.修改validation-config.xml中的配置文件
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE validation-config SYSTEM "validation-config.dtd"> <validation-config lang="auto"> <form id="form2" show-error="error" show-type="all"> <field name="name" display-name="姓名" onfail=""> <depend name="required" /> <depend name="commonChar" /> <depend name="minLength" param0="3"/> <depend name="maxLength" param0="20"/> </field> <field name="email" display-name="email邮箱"> <depend name="required" /> <depend name="email" /> </field> <field name="age" display-name="年纪"> <depend name="required" /> </field> <field name="code" display-name="编程时间"> <depend name="required" /> </field> <field name="os" display-name="使用的操作系统"> <depend name="required" /> </field> <field name="language" display-name="使用的编程语言"> <depend name="required" /> </field> <field name="comment" display-name="建议"> <depend name="required" /> </field> </form> </validation-config>
??
?