手机号码中间部分替换成星号

JS代码:

方法 ① :字符串截取+拼接


(phone) { ( phone ) { phonephone.(); } phone.(,) phone.(,); }

functionformatPhoneiftypeof==‘number‘ ==toStringtoStringreturnsubstr03+‘****‘****+substr711

方法 ②:正则表达式替换

         (phone) {
             phone.(,);
        }
                    functionformatPhonereturnreplace/(\d{3})\d{4}(\d{4})/344"$1****$2"$1****$2

相关文章

jquery.validate使用攻略(表单校验) 目录 jquery.validate...
/\s+/g和/\s/g的区别 正则表达式/\s+/g...
自整理几个jquery.Validate验证正则: 1. 只能输入数字和字母...
this.optional(element)的用法 this.optional(element)是jqu...
jQuery.validate 表单动态验证 实际上jQuery.validate提供了...
自定义验证之这能输入数字(包括小数 负数 ) <script ...