easyUi 验证电话

前端之家收集整理的这篇文章主要介绍了easyUi 验证电话前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//自定义验证
$.extend($.fn.validateBox.defaults.rules,{
phoneRex: {
  validator: function(value){
  var rex=/^1[3-8]+\d{9}$/;
  //var rex=/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
  //区号:前面一个0,后面跟2-3位数字 : 0\d{2,3}
  //电话号码:7-8位数字: \d{7,8
  //分机号:一般都是3位数字: \d{3,}
   //这样连接起来就是验证电话的正则表达式了:/^((0\d{2,}))?$/		 
  var rex2=/^((0\d{2,}))?$/;
  if(rex.test(value)||rex2.test(value))
  {
    // alert('t'+value);
    return true;
  }else
  {
   //alert('false '+value);
     return false;
  }
    
  },message: '请输入正确电话或手机格式'
}
});

<tr height="20">
			      <td width="135" align='right'>客户电话:</td>
			      <td width="165" align='left'>
				      <input class="easyui-validateBox" style="width:150px" name="tel" id="customer_tel" @R_502_103@="true" data-options="validType:'phoneRex'">
			      </td>  
			   </tr>
原文链接:https://www.f2er.com/regex/360573.html

猜你在找的正则表达式相关文章