$.extend($.fn.textbox.defaults.rules, {
number : {
validator : function(value, param) {
return /^[0-9]*$/.test(value);
},
message : "请输入数字"
},
chinese : {
validator : function(value, param) {
var reg = /^[\u4e00-\u9fa5]+$/i;
return reg.test(value);
},
message : "请输入中文"
},
checkLength: {
validator: function(value, param){
return param[0] >= get_length(value);
},
message: '请输入最大{0}位字符'
},
specialCharacter: {
validator: function(value, param){
var reg = new RegExp("[`~!@#$^&*()=|{}':;'\\[\\]<>~!@#¥……&*()——|{}【】‘;:”“'、?]");
return !reg.test(value);
},
message: '不允许输入特殊字符'
}
englishLowerCase : {// 验证英语小写
validator : function(value) {
return /^[a-z]+$/.test(value);
},
message : '请输入小写字母'
}
});
<div id="dlg" class="easyui-dialog" style=" width:400px; height:300px; padding:10px 20px;" data-options="resizable:true,modal:true" closed="true" buttons="#dlg-buttons">
<form id="fm" method="post" >
<table>
<tr>
<td class="normal" width="200px">登录名</td>
<td><input id="loginname_dlg" name="loginname_dlg" class="easyui-textbox" required="true" style="height:25px;" data-options="validType:['englishLowerCase','checkLength[50]']" >
<input id="id_dlg" name="id_dlg" type="hidden">
</td>
</tr>
<tr>
<td class="normal" width="200px">用户名</td>
<td><input id="username_dlg" name="username_dlg" class="easyui-textbox" required="true" style="height:25px;" data-options="validType:['chinese','checkLength[50]']"></td>
</tr>
<tr>
<td class="normal" width="200px">联系电话</td>
<td><input id="phone_dlg" name="phone_dlg" class="easyui-textbox" style="height:25px;" data-options="validType:['number','length[11,11]']" ></td>
</tr>
</table>
</form>
</div>
<div id="dlg-buttons">
<a id="dlg-save" href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" οnclick="save()">保存</a>
<a id="dlg-close" href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" οnclick="javascript:$('#dlg').dialog('close')">关闭</a>
</div>