console
const reg = /^1\d{10}$/g;
const msg = document.querySelector('.msg');
const input = document.querySelector('input');
input.oninput = function(){
console.log(reg.test(this.value));
if(reg.test(this.value)){
msg.style.display = 'none';
}else{
msg.style.display = 'block';
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="wrapper">
<div class="phone">
<span>手机号</span>
<input type="text">
</div>
<div class="msg">手机号格式不正确</div>
</div>
</body>
</html>
.wrapper{
margin: 40px;
}
.msg{
color: red;
margin-left: 50px;
}