<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>测试表单</title> <script type="text/javascript" src="js/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="js/themes/icon.css"> <script type="text/javascript" src="js/jquery.easyui.min.js"></script> <script type="text/javascript" src="js/locale/easyui-lang-zh_CN.js"></script> <script type="text/javascript"> $(function(){ $("#myform").form({ novalidate:false, url:'TestSubmit', onSubmit:function(){ var isValid = $(this).form('validate'); //alert('表单测试=' + isValid); if(!isValid) { $.messager.show({title:'表单验证',msg:'验证未通过'}); } return isValid; }, success:function(data){ alert(data) } }); $("#subbutton").click(function(){ $("#myform").form('submit'); }); }) </script> </head> <body> <div id="mypanel" class="easyui-panel" title="用户信息" style="300px;height:400px"> <form id="myform" action="" method="post" > <table> <tr> <td>用户名称:</td> <td><input class="easyui-textbox" data-options= "required:true,validType:'length[2,5]',invalidMessage:'名称错误'" width="30"></td> </tr> <tr> <td>密码:</td> <td><input class="easyui-textbox" data-options= "required:true,validType:'length[6,6]',type:'password',invalidMessage:'密码长度为6'" width="30"></td> </tr> <tr> <td>年龄:</td> <td><input class="easyui-numberbox" data-options= "required:true,precision:0,min:18,max:60" width="30"></td> </tr> <tr> <td>生日:</td> <td><input class="easyui-datebox" data-options="required:true,editable:false" width="30"></td> </tr> <tr> <td>城市:</td> <td><select class="easyui-combobox" style="100px"> <option value="0">未选择</option> <option value="1">北京</option> <option value="2">天津</option> </select></td> </tr> <tr> <td>城市1:</td> <td><input id="yij" class="easyui-combobox" style="100px" data-options="valueField:'id', textField:'name',url:'JsonMembers?parentid=0',editable:false,value:'-1', onSelect: function(rec){ var url='JsonMembers?parentid=' + rec.id; $('#erj').combobox('clear'); $('#erj').combobox('reload',url); $('#erj').combobox('setValue','-1'); $('#sanj').combobox('clear'); $('#sanj').combobox('reload',url); $('#sanj').combobox('setValue','-1'); }"> </td> </tr> <tr> <td>城市2:</td> <td><input id="erj" class="easyui-combobox" style="100px" data-options="valueField:'id',editable:false, textField:'name',url:'JsonMembers',value:'-1', onSelect: function(rec){ var url='JsonMembers?parentid=' + rec.id; $('#sanj').combobox('clear'); $('#sanj').combobox('reload',url) $('#sanj').combobox('setValue','-1') }"> </td> </tr> <tr> <td>城市3:</td> <td><input id="sanj" class="easyui-combobox" style="100px" data-options="valueField:'id',editable:false, textField:'name',url:'JsonMembers',value:'-1'"> </td> </tr> <tr> <td>工资:</td> <td><input class="easyui-numberbox" data-options= "required:true,precision:2,min:0,max:6000,prefix:'$'" width="30"></td> </tr> <tr> <td>用户邮箱:</td> <td><input class="easyui-textbox" data-options= "required:true,validType:'email',missingMessage:'这是必填项'" width="30"></td> </tr> <tr> <td>个人主页:</td> <td><input class="easyui-textbox" data-options= "required:false,validType:'url',iconCls:'icon-search',prompt:'提示信息'" width="30"></td> </tr> <tr> <td>注册时间:</td> <td><input class="easyui-datetimebox" data-options="required:true,editable:false" width="30"></td> </tr> <tr> <td colspan=2 align="center"> <a id="subbutton" class="easyui-linkbutton" style="80px;">提交</a> </td> </tr> </table> </form> </div> </body> </html>