1、手机号码
<div style="padding:3px;">
<label for="phone">联系电话:</label>
<input id="phone" type="text" name="phone" class="easyui-validatebox textbox" data-options="required:true,validType:'phoneRex'"/>
</div>
<script>
//自定义验证
$.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,3})-)(\d{7,8})(-(\d{3,}))?$/
var rex2=/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
if(rex.test(value)||rex2.test(value))
{
// alert('t'+value);
return true;
}else
{
//alert('false '+value);
return false;
}
},
message: '请输入正确电话或手机格式'
}
});
</script>
2、邮箱
<div style="padding:3px;">
<label for="email">邮箱:</label>
<input id="email" type="text" name="email" class="easyui-validatebox textbox" data-options="required:true,validType:['email','length[0,20]']"/>
</div>
网友评论