1. js中进行验证设置
$.extend($.fn.validatebox.defaults.rules, {phoneRex: {// 手机validator: function (value) {var rex = /^1[3-8]+\d{9}$/;if (rex.test(value)) {return true;} else {return false;}},message: '请输入正确的手机号码格式'},telNum: {// 座机validator: function (value) {var rex2 = /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;if (rex2.test(value)) {return true;} else {return false;}},message: '请输入正确的电话号码格式'}});
2. 界面中进行验证即可
<input class="easyui-textbox" name="phone" style="width:100%" data-options="label:'电话:',required:true,validType:'phoneRex'">