小程序开发中判断判断手机号是否11位数字
function checkMobile(str) { //写一个判断函数
var re = /^1\d{10}$/ //正则表达式,这种是正则
if (re.test(str)) { //判断字符是否是11位数字
$( "#sj" ).html( "手机号码格式正确" );
$( "#sj" ).css( "color" , "green" );
}
else {
$( "#sj" ).html( "手机号码格式错误" );
$( "#sj" ).css( "color" , "red" );
}
}
$( "#tel" ).blur( function (){
var str = $(this).val(); //取值
checkMobile(str);
})
网页标题:小程序开发中判断判断手机号是否11位数字
标题来源:http://www.myadxq.com/view/109182.html


咨询
建站咨询
