// 匹配手机号首尾,以类似“123****8901”的形式输出
'12345678901'.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
var phone='12345678901';
var dh=phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
alert (dh);
</script>
</head>
<body>
</body>
</html>
// 匹配连续11位数字,并替换其中的前7位为*号
'15110280327'.replace(/\d{7}(\d{4})/, '*******$1');
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
var phone='12345678901';
var dh=phone.replace(/\d{7}(\d{4})/, '*******$1');
alert (dh);
</script>
</head>
<body>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>js手机号码验证以及隐藏中间四位数字</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input type="text" id="myText">
<p>js手机验证以及隐藏手机号码中间四位</p>
<input type="button" value="提交" id="subBtn">
<script type='text/javascript'>
$(function(){
$("#subBtn").click(function(){
if($("#myText").val()==""){
alert("手机号码不能为空")
}else{
if(iphoneCheck(myText)){
alert("提交成功");
var phone=$("#myText").val();
var myphone=phone.substr(3,4);
//alert(myphone)
var lphone=phone.replace(myphone,"****");
$("#myText").val(lphone);
}else{
alert("请输入正确的手机号码")
}
}
function iphoneCheck(id){
var temp=document.getElementById("myText");
var re=/^[1][34587]\d{9}$/;//手机号码验证正则表达式
if(re.test(temp.value)){
return true;
}else{
return false;
}
}
});
});
</script>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有