78cbdf81f33f5b35dffb63f291c39f96de6cbf9d.svn-base 25 KB

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