1. 程式人生 > >Jquery easyUi表單驗證提交

Jquery easyUi表單驗證提交

  1. <form id="myForm" method="post">  
  2.         <table align="center" style="width:400px;height:auto;margin-top: 20px">    
  3.             <tr>                                
  4.                 <td align="right">命令:</td>      
  5.                 <td><input id="cmd" name="cmd" style="width: 200px;" class="easyui-validatebox" required="true" validType="length[5,12]" missingMessage="不能為空"/></td>   
  6.             </tr>  
  7.             <tr>                
  8.                 <td align="right">描述:</td>  
  9.                  <td><input id="depict" name="depict" style="width: 200px;" class="easyui-validatebox" required="true" validType="length[5,12]" missingMessage="不能為空"/></td>   
  10.             </tr>  
  11.             <tr>                 
  12.                 <td align="right">型別:</td>                 
  13.                 <td><input id="type" style="width: 200px" class="easyui-validatebox"  
  14.                     url="data/editHealthCheckCombobox_data.json" valueField="id"  
  15.                     textField="text" /></td>   
  16.             </tr>   
  17.             <tr>  
  18.                 <td align="right">分數:</td>                 
  19.                 <td><input id="score" name="score" style="width: 200px" valueField="number"/></td>   
  20.             </tr>  
  21.             <tr>   
  22.                 <td align="right">使用狀況:</td>                 
  23.                 <td><input id="isUse" style="width: 200px" class="easyui-validatebox"/></td>   
  24.             </tr>   
  25.             <tr>   
  26.                 <td align="center" colspan="2">  
  27.                     <input type="submit"  value="提交"/>  
  28.                     <input type="reset" value="重置"/>  
  29.                 </td>                 
  30.             </tr>  
  31.         </table>  
  32.     </form>  
<form id="myForm" method="post">
		<table align="center" style="width:400px;height:auto;margin-top: 20px">  
	        <tr>                              
	            <td align="right">命令:</td>    
	            <td><input id="cmd" name="cmd" style="width: 200px;" class="easyui-validatebox" required="true" validType="length[5,12]" missingMessage="不能為空"/></td> 
	        </tr>
	        <tr>              
	            <td align="right">描述:</td>
	     		 <td><input id="depict" name="depict" style="width: 200px;" class="easyui-validatebox" required="true" validType="length[5,12]" missingMessage="不能為空"/></td> 
	        </tr>
	        <tr>               
	            <td align="right">型別:</td>               
	            <td><input id="type" style="width: 200px" class="easyui-validatebox"
					url="data/editHealthCheckCombobox_data.json" valueField="id"
					textField="text" /></td> 
	        </tr> 
	        <tr>
	            <td align="right">分數:</td>               
	            <td><input id="score" name="score" style="width: 200px" valueField="number"/></td> 
	        </tr>
	        <tr> 
	            <td align="right">使用狀況:</td>               
	            <td><input id="isUse" style="width: 200px" class="easyui-validatebox"/></td> 
	        </tr> 
	        <tr> 
	            <td align="center" colspan="2">
	            	<input type="submit"  value="提交"/>
					<input type="reset" value="重置"/>
	            </td>               
	        </tr>
		</table>
	</form>
[javascript] view plaincopyprint?
  1. //表單提交   
  2.     $('#myForm').form({  
  3.         url:'/ProcessServlet',  
  4.         onSubmit:function(){  
  5.             return $(this).form('validate');  
  6.         },  
  7.         success:function(data){  
  8.             alert(data);  
  9.         }  
  10.     });