验证正确的手机格式和统计数量大于0,激活按钮。否则按钮为灰。用Js实现。请各位大牛帮忙。
var isChinaMobile = /^134[0-8]d{7}$|^(?:13[5-9]|147|15[0-27-9]|178|18[2-478])d{8}$/; //移动
var isChinaUnion = /^(?:13[0-2]|145|15[56]|176|18[56])d{8}$/; //联通
var isChinaTelcom = /^(?:133|153|177|18[019])d{8}$/; // 电信
var isOtherTelphone = /^170([059])d{7}$/;//其他运营商
var utils = {
checkMobile: function(telphone){
telphone = this.trim(telphone);
if(telphone.length !== 11){
return this.setReturnJson(false, '未检测到正确的手机号码');
}
else{
if(isChinaMobile.test(telphone)){
return this.setReturnJson(true, '移动', {name: 'ChinaMobile'});
}
else if(isChinaUnion.test(telphone)){
return this.setReturnJson(true, '联通', {name: 'ChinaUnion'});
}
else if(isChinaTelcom.test(telphone)){
return this.setReturnJson(true, '电信', {name: 'ChinaTelcom'});
}
else if(isOtherTelphone.test(telphone)){
var num = isOtherTelphone.exec(telphone);
return this.setReturnJson(true, '', {name: ''});
}
else{
return this.setReturnJson(false, '未检测到正确的手机号码');
}
}
},
setReturnJson: function(status, msg, data){
if(typeof status !== 'boolean' && typeof status !== 'number'){
status = false;
}
if(typeof msg !== 'string'){
msg = '';
}
return {
'status': status,
'msg': msg,
'data': data
};
}
}
<script type="text/javascript">
var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+d{8})$/;// 验证130-139,150-159,180-189号码段的手机号码
if(!myreg.test($("#phone").val()))
{
alert('请输入有效的手机号码!');
return false;
}
</script>
function validatemobile(mobile)
{
if(mobile.length==0)
{
alert('请输入手机号码!');
document.form1.mobile.focus();
return false;
}
if(mobile.length!=11)
{
alert('请输入有效的手机号码!');
document.form1.mobile.focus();
return false;
}
var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+d{8})$/;
if(!myreg.test(mobile))
{
alert('请输入有效的手机号码!');
document.form1.mobile.focus();
return false;
}
}
var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
if (reg.test($("#手机输入框").val() && 统计数量 > 0))
$("#按钮").removeAttr("disabled");
else
$("#按钮")..attr({"disabled":"disabled"};
var reg = /^1\d{10}$/;
var countNum = 1;
var telPhone = "13933333444";
var $thisBtn = document.getElementById("btnId");
var backColor = $thisBtn.background;
if(reg.test(telPhone) && countNum > 1){
$thisBtn.disabled = true;
$thisBtn.background = "gray";
}else{
$thisBtn.disabled = false;
$thisBtn.background = backColor;
}
/*
* 功能:判断用户输入的手机号格式是否正确
* 传参:无
* 返回值:true or false
*/
function checkMobile(s) {
var regu = /^[1][0-9][0-9]{9}$/;
var re = new RegExp(regu);
if (re.test(s)) {
return true;
} else {
return false;
}
}
统计数量具体是统计什么?