标签:
js代码
1 function validate(){ 2 $.extend($.fn.validatebox.defaults.rules, { 3 maxLength: { 4 validator: function(value, param){ 5 return value.length <= param[0]; 6 }, 7 message: ‘最多输入 {0} 位‘ 8 }, 9 onlyLength:{ 10 validator: function(value, param){ 11 if(!isNaN(value) ){ 12 return value.length == param[0]; 13 }else{ 14 return false; 15 } 16 }, 17 message: ‘必须是 {0} 位数字‘ 18 }, 19 selectValueRequired:{ 20 validator: function(value,param){ 21 console.info($(param[0]).find("option:contains(‘"+value+"‘)").val()); 22 return $(param[0]).find("option:contains(‘"+value+"‘)").val() != ‘‘; 23 } 24 } 25 }); 26 }
jsp代码
1 <input class="easyui-validatebox" type="text" name="code" data-options="required:true,validType:‘maxLength[12]‘" /> 2 3 <!-- 下拉框非空验证 --> 4 5 <select name="status" class="easyui-combobox" required="true" validType="selectValueRequired[‘#test‘]" > 6 <option value="1" >启用</option> 7 <option value="0" >禁用</option> 8 </select>
标签:
原文地址:http://www.cnblogs.com/7eus/p/5018592.html