5ded45ba0dca42372a0b0ddb22c8d25ff8c0c13b.svn-base 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  9. <title>表单验证</title>
  10. <!-- 框架必需start -->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!-- 框架必需end -->
  18. <!-- 树组件start -->
  19. <script type="text/javascript" src="<%=path%>/libs/js/tree/ztree/ztree.js"></script>
  20. <link type="text/css" rel="stylesheet" href="<%=path%>/libs/js/tree/ztree/ztree.css"></link>
  21. <!-- 树组件end -->
  22. <!-- 树形下拉框start -->
  23. <script type="text/javascript" src="<%=path%>/libs/js/form/selectTree.js"></script>
  24. <!-- 树形下拉框end -->
  25. <!-- 日期控件start -->
  26. <script type="text/javascript" src="<%=path%>/libs/js/form/datePicker/WdatePicker.js"></script>
  27. <!-- 日期控件end -->
  28. <!-- 条件过滤器 start -->
  29. <script type="text/javascript" src="<%=path%>/libs/js/form/filter.js"></script>
  30. <!-- 条件过滤器 end -->
  31. <!-- 数字步进器start -->
  32. <script type="text/javascript" src="<%=path%>/libs/js/form/stepper.js"></script>
  33. <!-- 数字步进器end -->
  34. <!-- 软键盘控件start -->
  35. <script type="text/javascript" src="<%=path%>/libs/js/form/keypad.js"></script>
  36. <!-- 软键盘控件end -->
  37. <!-- 双向选择器start -->
  38. <script type="text/javascript" src="<%=path%>/libs/js/form/lister.js"></script>
  39. <!-- 双向选择器end -->
  40. <!--自动提示框start-->
  41. <script type='text/javascript' src='<%=path%>/libs/js/form/suggestion.js'></script>
  42. <!--自动提示框end-->
  43. <!-- 树形双选器start -->
  44. <script type="text/javascript" src="<%=path%>/libs/js/form/listerTree.js"></script>
  45. <!-- 树形双选器end -->
  46. <!-- 组合下拉框start -->
  47. <script type="text/javascript" src="<%=path%>/libs/js/form/selectCustom.js"></script>
  48. <!-- 组合拉框end -->
  49. <!-- 表单验证start -->
  50. <script src="<%=path%>/libs/js/form/validationRule.js" type="text/javascript"></script>
  51. <script src="<%=path%>/libs/js/form/validation.js" type="text/javascript"></script>
  52. <!-- 表单验证end -->
  53. </head>
  54. <body>
  55. <div class="box1">
  56. <fieldset>
  57. <legend>1、基本使用</legend>
  58. <form id="form1" method="post" action="" failAlert="表单填写不正确,请按要求填写!">
  59. <table class="tableStyle" formMode="line" style="width:1060px;">
  60. <tr>
  61. <th colspan="4">表单填写</th>
  62. </tr>
  63. <tr>
  64. <td width="150">用户名:</td><td width="300"><input type="text" class="validate[required,custom[noSpecialCaracters]]" watermark="请输入英文或数字"/><span class="star">*</span></td>
  65. <td width="150">姓名:</td><td width="300"><input type="text" class="validate[required,custom[chinese],length[0,20]]"/><span class="star">*</span></td>
  66. </tr>
  67. <tr>
  68. <td>密码:</td><td><input type="password" id="pwd" class="validate[required,length[6,11],custom[noSpecialCaracters]]"/><span class="star">*</span> </td>
  69. <td>密码确认:</td><td><input type="password" class="validate[required,confirm[pwd]]"/><span class="star">*</span></td>
  70. </tr>
  71. <tr>
  72. <td>爱好:</td><td>
  73. <div id="hobby" style="width:135px;" class="checkboxRender"><input type="checkbox" id="checkbox-1" class="validate[minCheckbox[1]] checkbox" name="ck1" value="选项1"/><label for="checkbox-1" class="hand">唱歌</label>
  74. <input type="checkbox" id="checkbox-2" class="validate[minCheckbox[1]] checkbox" name="ck1" value="选项2" /><label for="checkbox-2" class="hand">跳舞</label> <span class="star">*</span></div>
  75. </td>
  76. <td>性别:</td>
  77. <td><div style="width:135px;" class="checkboxRender"><input type="radio" class="validate[required] radio" id="radio-1" name="ra" value="radio-1" /><label for="radio-1" class="hand">男</label>
  78. <input type="radio" id="radio-2" name="ra" class="validate[required] radio" value="radio-2"/><label for="radio-2" class="hand">女</label> <span class="star">*</span></div>
  79. </td>
  80. </tr>
  81. <tr>
  82. <td>年龄:</td><td><input type="text" watermark="请输入数字" class="validate[required,custom[onlyNumber],length[0,3]]"/><span class="star">*</span></td>
  83. <td>电子邮件:</td>
  84. <td>
  85. <input type="text" class="validate[required,custom[email]]"/><span class="star">*</span>
  86. </td>
  87. </tr>
  88. <tr>
  89. <td>固定电话:</td><td><input type="text" class=" validate[required,custom[telephone]]"/><span class="star">*</span></td>
  90. <td>英文名:</td><td><input type="text" class="validate[required,custom[onlyLetter]]"/><span class="star">*</span></td>
  91. </tr>
  92. <tr>
  93. <td>手机号码:</td><td><input type="text" class=" validate[required,custom[mobilephone]]"/><span class="star">*</span></td>
  94. <td>邮政编码:</td><td><input type="text" class=" validate[required,custom[zipcode]]"/><span class="star">*</span></td>
  95. </tr>
  96. <tr>
  97. <td>QQ:</td><td><input type="text" class=" validate[required,custom[qq]]"/><span class="star">*</span></td>
  98. <td>非法字符:</td>
  99. <td>
  100. <input type="text" class=" validate[required,custom[illegalLetter]]"/><span class="star">*</span>
  101. </td>
  102. </tr>
  103. <tr>
  104. <td>IP地址:</td><td><input type="text" class=" validate[required,custom[ip]]"/><span class="star">*</span></td>
  105. <td>非负整数:</td><td><input type="text" class=" validate[required,custom[onlyNumber]]"/><span class="star">*</span></td>
  106. </tr>
  107. <tr>
  108. <td>正负小数:</td><td><input type="text" class=" validate[required,custom[onlyDecimal]]"/><span class="star">*</span></td>
  109. <td>正负整数与小数:</td><td><input type="text" class=" validate[required,custom[onlyNumberWide]]"/><span class="star">*</span></td>
  110. </tr>
  111. <tr>
  112. <td>单选下拉框:</td><td><select class="validate[required]" prompt="请选择" data='{"list":[{"value":"1","key":"北京"},{"value":"2","key":"黑龙江"}]}'></select><span class="star">*</span></td>
  113. <td>树形单选下拉框:</td><td><div class="selectTree validate[required]" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div><span class="star">*</span> </td>
  114. </tr>
  115. <tr>
  116. <td>多选下拉框:</td><td><div class="selectTree validate[required]" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"员工1"},{ "id":"2", "parentId":"0", "name":"员工2"},{ "id":"3", "parentId":"0", "name":"员工3"},{ "id":"4", "parentId":"0", "name":"员工4"}]}' multiMode="true" noGroup="true"></div><span class="star">*</span> </td>
  117. <td>树形多选下拉框:</td><td><div class="selectTree validate[required]" data='{"treeNodes":[{"id":"1","parentId":"0","name":"部门1","nocheck":"true","clickExpand":"true","open":"true"},{"id":"11","parentId":"1", "name":"员工1"},{"id":"12","parentId":"1", "name":"员工2"},{"id":"13","parentId":"1", "name":"员工3"},{"id":"2","parentId":"0","name":"部门2","nocheck":"true","clickExpand":"true","open":"true"},{"id":"21","parentId":"2", "name":"员工4"}]}' multiMode="true"></div><span class="star">*</span> </td>
  118. </tr>
  119. <tr>
  120. <td>数字步进器:</td><td><input id="step1" type="text" class="stepper validate[required]"/><span class="star">*</span> </td>
  121. <td>软键盘控件:</td><td><input class="keypad validate[required]" type="text"/><span class="star">*</span></td>
  122. </tr>
  123. <tr>
  124. <td>自动提示框:</td><td> <div class="suggestion validate[required]" id="suggestion1" keepDefaultStyle="true" showList="true"></div><span class="star">*</span> </td>
  125. <td>日期选择框:</td><td><input type="text" class="date validate[required,custom[date]]"/><span class="star">*</span></td>
  126. </tr>
  127. <tr>
  128. <td>条件过滤器:</td>
  129. <td colspan="3">
  130. <div class="float_left">
  131. <div class="filter validate[required]" filterWidth="355" data='{"list":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}]}'></div>
  132. </div>
  133. <div class="float_left padding_top5">
  134. <span class="star float_left">*</span>
  135. </div>
  136. <div class="clear"></div>
  137. </td>
  138. </tr>
  139. <tr>
  140. <td>双向选择器:</td>
  141. <td colspan="3">
  142. <div class="float_left">
  143. <div class="lister validate[required]" listerWidth="140" listerHeight="120" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div>
  144. </div>
  145. <div class="float_left" style="padding:90px 0 0 0;">
  146. <span class="star float_left">*</span>
  147. </div>
  148. <div class="clear"></div>
  149. </td>
  150. </tr>
  151. <tr>
  152. <td>树形双选器:</td>
  153. <td colspan="3">
  154. <div class="float_left">
  155. <div class="listerTree validate[required]" listerWidth="140" listerHeight="120" data='{"toList":[],"fromList":[{"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},{"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},{"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},{"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},{"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}]}'></div>
  156. </div>
  157. <div class="float_left" style="padding:80px 0 0 0;">
  158. <span class="star float_left">*</span>
  159. </div>
  160. <div class="clear"></div>
  161. </td>
  162. </tr>
  163. <tr>
  164. <td>文本域:</td>
  165. <td colspan="3">
  166. <div class="float_left">
  167. <textarea class="validate[required]" style="width:350px;"></textarea>
  168. </div>
  169. <div class="float_left" style="padding:40px 0 0 0;">
  170. <span class="star float_left">*</span>
  171. </div>
  172. <div class="clear"></div>
  173. </td>
  174. </tr>
  175. <tr>
  176. <td>组合下拉框:</td>
  177. <td colspan="3">
  178. <div class="selectCustom validate[required]" boxWidth="380" prompt="请选择一种格式" id="selectCostom5">
  179. <div id="customContent5" style="font-size:12px;padding:0 0 10px 10px;">
  180. <div class="navIconSmall" id="MP3">
  181. <img src="<%=path%>/libs/icons/png/16.png"/><br />
  182. MP3格式
  183. </div>
  184. <div class="navIconSmall" id="WMA">
  185. <img src="<%=path%>/libs/icons/png/21.png"/><br />
  186. WMA格式
  187. </div>
  188. <div class="navIconSmall" id="AVI">
  189. <img src="<%=path%>/libs/icons/png/25.png"/><br />
  190. AVI格式
  191. </div>
  192. <div class="navIconSmall" id="WAVE">
  193. <img src="<%=path%>/libs/icons/png/24.png"/><br />
  194. WAVE格式
  195. </div>
  196. <div class="navIconSmall" id="MIDI">
  197. <img src="<%=path%>/libs/icons/png/30.png"/><br />
  198. MIDI格式
  199. </div>
  200. <div class="navIconSmall" id="MPEG">
  201. <img src="<%=path%>/libs/icons/png/29.png"/><br />
  202. MPEG格式
  203. </div>
  204. <div class="navIconSmall" id="TIF">
  205. <img src="<%=path%>/libs/icons/png/22.png"/><br />
  206. TIF格式
  207. </div>
  208. <div class="navIconSmall" id="PNG">
  209. <img src="<%=path%>/libs/icons/png/23.png"/><br />
  210. PNG格式
  211. </div>
  212. <div class="navIconSmall" id="JPEG">
  213. <img src="<%=path%>/libs/icons/png/33.png"/><br />
  214. JPEG格式
  215. </div>
  216. <div class="navIconSmall" id="TGA">
  217. <img src="<%=path%>/libs/icons/png/15.png" width="60" height="60"/><br />
  218. TGA格式
  219. </div>
  220. <div class="navIconSmall" id="GIF">
  221. <img src="<%=path%>/libs/icons/png/33.png"/><br />
  222. GIF格式
  223. </div>
  224. <div class="navIconSmall" id="BMP">
  225. <img src="<%=path%>/libs/icons/png/37.png"/><br />
  226. BMP格式
  227. </div>
  228. <div class="clear"></div>
  229. </div>
  230. </div>
  231. <span class="star">*</span>
  232. </td>
  233. <tr>
  234. <td>同步上传控件:</td>
  235. <td colspan="3">
  236. <div class="float_left">
  237. <input type="file" showInfo="false" class="validate[required,custom[onlyImage]]"/>
  238. </div>
  239. <div class="float_left" style="padding:5px 0 0 0;">
  240. <span class="star float_left">*</span> (可验证文件格式)
  241. </div>
  242. <div class="clear"></div>
  243. </td>
  244. </tr>
  245. <tr>
  246. <td colspan="4">
  247. <input type="button" value=" 提 交 " onclick="validateForm('#form1');"/>
  248. <input type="button" value=" 重 置 "/>
  249. </td>
  250. </tr>
  251. </table>
  252. </form>
  253. </fieldset>
  254. <div class="height_15"></div>
  255. <fieldset>
  256. <legend>2、手动触发验证</legend>
  257. <p>点击按钮后,对上面的表单手动触发一次验证。</p>
  258. <input type="button" value="点击验证“爱好”复选框" onclick="validateForm('#hobby');"/>
  259. <input type="button" value="点击验证上面的表单" onclick="validateForm('#form1');"/>
  260. <p>
  261. 手动验证多用于异步提交表单的情况。在提交表单前手动验证,如果验证通过再调用函数进行表单的异步提交。详见:表单异步提交内容
  262. </p>
  263. </fieldset>
  264. <div class="height_15"></div>
  265. <fieldset>
  266. <legend>3、ajax验证</legend>
  267. <div class="red">此示例由后台支持</div>
  268. 可输入已存在用户名进行测试,例如:guest、an、kong、yang等<br/>
  269. <form id="form3" method="post" action="" failAlert="验证未通过!">
  270. <table style="width:400px;" class="tableStyle" formMode="transparent">
  271. <tr>
  272. <td width="100">用户名:</td><td><input type="text" class="validate[required,custom[noSpecialCaracters],ajax[<%=path%>/validateUserName.action|* 用户名已存在!]]"/><span class="star">*</span></td>
  273. </tr>
  274. <tr>
  275. <td colspan="2"><input type="button" onclick="ajaxHander()" value="提交"/></td></td>
  276. </tr>
  277. </table>
  278. </form>
  279. </fieldset>
  280. <div class="height_15"></div>
  281. <fieldset>
  282. <legend>4、为动态创建的表单添加验证</legend>
  283. <input type="button" value="创建新表单" onclick="addNewForm()" id="testBtn"/>
  284. </fieldset>
  285. <div class="height_15"></div>
  286. <fieldset>
  287. <legend>5、为元素动态添加并触发验证</legend>
  288. 此例为复选框选中后,电子邮件必填;不选中则为非必填项。<br/>
  289. <form id="form4" method="post" action="" failAlert="请将表单填写完整!">
  290. <table class="tableStyle" formMode="line" style="width:800px;">
  291. <tr>
  292. <th colspan="2">表单填写</th>
  293. </tr>
  294. <tr>
  295. <td width="200">用户名:</td>
  296. <td><input type="text" class="validate[required,custom[noSpecialCaracters]]"/><span class="star">*</span></td>
  297. </tr>
  298. <tr>
  299. <td>是否愿意留下邮箱:</td><td><input type="checkbox" id="myCheck" onclick="emailChange();"/></td>
  300. </tr>
  301. <tr>
  302. <td>电子邮件:</td><td id="emailContainer"><input type="text" id="emailInput" class="validate[custom[email]]"/><span id="emailTip" class="star"></span></td>
  303. </tr>
  304. <tr>
  305. <td colspan="2">
  306. <input type="submit" value=" 提 交 "/>
  307. <input type="reset" value=" 重 置 "/>
  308. </td>
  309. </tr>
  310. </table>
  311. </form>
  312. </fieldset>
  313. <div class="height_15"></div>
  314. <fieldset>
  315. <legend>6、设置不允许输入的内容</legend>
  316. 此例中,不允许输入admin<br/>
  317. <form id="form4" method="post" action="" >
  318. <table class="tableStyle" formMode="line" style="width:800px;">
  319. <tr>
  320. <th colspan="2">表单填写</th>
  321. </tr>
  322. <tr>
  323. <td width="200">用户名:</td>
  324. <td><input type="text" class="validate[required,exemptString[admin|不允许输入admin]]"/><span class="star">*</span></td>
  325. </tr>
  326. <tr>
  327. <td colspan="2">
  328. <input type="submit" value=" 提 交 "/>
  329. <input type="reset" value=" 重 置 "/>
  330. </td>
  331. </tr>
  332. </table>
  333. </form>
  334. 可对一个文本框可同时设置多个不允许输入的内容。
  335. </fieldset>
  336. <div class="height_15"></div>
  337. <fieldset>
  338. <legend>7、页面添加验证函数</legend>
  339. 此例中,不允许输入小于50的数字<br/>
  340. <form id="form4" method="post" action="" >
  341. <table class="tableStyle" formMode="line" style="width:800px;">
  342. <tr>
  343. <th colspan="2">表单填写</th>
  344. </tr>
  345. <tr>
  346. <td width="200">金额:</td>
  347. <td><input type="text" class="validate[required,custom[onlyNumber],functionCall[func1|* 金额不能小于50]]" id="input1"/><span class="star">*</span></td>
  348. </tr>
  349. <tr>
  350. <td colspan="2">
  351. <input type="submit" value=" 提 交 "/>
  352. <input type="reset" value=" 重 置 "/>
  353. </td>
  354. </tr>
  355. </table>
  356. </form>
  357. 此方式有两个特点:<br/>
  358. 1、在页面中添加规则函数,这样可以在不改变规则文件validationRule.js的前提下添加个性化的验证。<br/>
  359. 2、可以不用正则表达式,而是通过一些规则计算来判断是否符合要求。不符合规则的话让该函数返回true即可。<br/>
  360. </fieldset>
  361. </div>
  362. <script type="text/javascript">
  363. var listdata={"list":[
  364. {value:"1",key:"北京",suggest:"北京|beijing|bj"},
  365. {value:"2",key:"广州",suggest:"广州|guangzhou|gz"},
  366. {value:"3",key:"深圳",suggest:"深圳|shenzhen|sz"},
  367. {value:"4",key:"上海",suggest:"上海|shanghai|sh"},
  368. {value:"5",key:"长沙",suggest:"长沙|changsha|cs"},
  369. {value:"6",key:"成都",suggest:"成都|chengdu|cd"},
  370. {value:"7",key:"贵阳",suggest:"贵阳|guiyang|gy"},
  371. {value:"8",key:"海口",suggest:"海口|haikou|hk"},
  372. {value:"9",key:"杭州",suggest:"杭州|hangzhou|hz"},
  373. {value:"10",key:"昆明",suggest:"昆明|kunming|km"},
  374. {value:"11",key:"南昌",suggest:"南昌|nanchang|nc"},
  375. {value:"12",key:"南京",suggest:"南京|nanjing|nj"},
  376. {value:"13",key:"三亚",suggest:"三亚|sanya|sy"},
  377. {value:"14",key:"沈阳",suggest:"沈阳|shenyang|sy"},
  378. {value:"15",key:"温州",suggest:"温州|wenzhou|wz"},
  379. {value:"16",key:"武汉",suggest:"武汉|wuhan|wh"},
  380. {value:"17",key:"厦门",suggest:"厦门|xiamen|xm"},
  381. {value:"18",key:"西安",suggest:"西安|xian|xa"},
  382. {value:"19",key:"郑州",suggest:"郑州|zhenghou|zz"},
  383. {value:"20",key:"汕头",suggest:"汕头|shantou|st"},
  384. {value:"21",key:"太原",suggest:"太原|taiyuan|ty"},
  385. {value:"22",key:"天津",suggest:"天津|tianjin|tj"}]};
  386. $(function(){
  387. $("#suggestion1").data("data",listdata);
  388. $("#suggestion1").render();
  389. $(".navIconSmall").each(function(){
  390. $(this).hover(function(){
  391. $(this).addClass("navIconSmall_hover");
  392. },function(){
  393. $(this).removeClass("navIconSmall_hover");
  394. })
  395. $(this).click(function(){
  396. $(".navIconSmall").removeClass("navIconSmall_current");
  397. $(this).addClass("navIconSmall_current");
  398. $("#selectCostom5").setValue($(this).attr("id"),$(this).text().trim());
  399. })
  400. })
  401. })
  402. //手动触发验证,被验证的表单元素是containerId容器里的。 可以验证整个表单,也可以验证部分表单。
  403. function validateForm(containerId){
  404. var valid = $(containerId).validationEngine({returnIsValid: true});
  405. if(valid == true){
  406. top.Dialog.alert('进行提交处理');
  407. }else{
  408. top.Dialog.alert('表单填写不正确,请按要求填写!');
  409. }
  410. }
  411. function addNewForm(){
  412. var $table=$(' <form id="form2" method="post" action="" failAlert="表单填写不正确,请按要求填写!">'+
  413. '<table class="tableStyle" formMode="line" style="width:500px;">'+
  414. '<tr><th colspan="2">动态添加验证功能</th></tr>'+
  415. '<tr><td>用户名:</td><td><input type="text" id="inputa1" class="validate[required,custom[noSpecialCaracters]]" /><span class="star">*</span></td></tr>'+
  416. '<tr><td>密码:</td><td><input type="password" id="inputa2" class="validate[required,length[6,11],custom[noSpecialCaracters]]"/><span class="star">*</span></td></tr> '+
  417. '<tr><td>籍贯:</td><td><select id="inputa3" class="validate[required]" prompt="请选择"></select><span class="star">*</span></td></tr>'+
  418. '<tr><td colspan="2"><input type="submit" value="提交" id="inputa4"/>&nbsp;<input type="reset" value="重置" id="inputa5"/></td></tr>'+
  419. '</table></form>')
  420. $("#testBtn").after($table);
  421. $table.find("table").render();
  422. $table.find("#inputa1").render();
  423. $table.find("#inputa2").render();
  424. $table.find("#inputa3").data("data",{"list":[{"value":"1","key":"北京"},{"value":"2","key":"黑龙江"}]});
  425. $table.find("#inputa3").render();
  426. $table.find("#inputa4").render();
  427. $table.find("#inputa5").render();
  428. $table.validationEngine();
  429. }
  430. //"是否愿意留下邮箱"值变化
  431. function emailChange(){
  432. var checked = $('#myCheck').attr('checked');
  433. if(checked){
  434. $("#emailInput").addClass("validate[required]");
  435. $("#emailTip").html("*");
  436. }else{
  437. $("#emailInput").removeClass("validate[required]");
  438. $("#emailTip").html("");
  439. }
  440. //调用校验方法,使文本框显示的样式及提示正确
  441. $("#emailContainer").validationEngine({returnIsValid: true});
  442. }
  443. function ajaxHander(){
  444. var valid = $("#form3").validationEngine({returnIsValid: true});
  445. if(valid){
  446. top.Dialog.alert("验证通过,此处是提交表单的处理!");
  447. }
  448. }
  449. function func1(){
  450. if(Number($("#input1").val())<50){
  451. return true;
  452. }
  453. return false;
  454. }
  455. </script>
  456. </body>
  457. </html>