js邮编、手机号、姓名限定

联系电话:<input type="text" name="lxdh" id="lxdh" onblur="checkPhone()" style="500px;">
<div id="sjh" style="color:red;display:none">手机号有误!</div>
 联 系 人:<input type="text" name="xm" onblur="uname1()" id="xm" style="500px;"><br>
  <div id="lxr" style="color:red;display:none">姓名填写有误!</div>
 
邮政编码:<input type="text" name="yzbm" id="yzbm" onblur="ischeck()"  style="500px;">
<div id="yzbm1" style="color:red;display:none">邮政编码有误!</div>



function ischeck(){//验证邮政编码
    var yb = document.getElementById('yzbm').value;
    if(!(/^[0-8][0-7]d{4}$/.test(yb))){ 
        document.getElementById("yzbm1").style.display="block"; 
         // alert("邮政编码格式不符合要求");
        return false; 
    } document.getElementById("yzbm1").style.display="none";  
    return true; 
}
function uname1(){
          var name = $('#xm').val();
    var regName =/^[u4E00-u9FA5uf900-ufa2d·s]{2,20}$/;  
    if(!regName.test(name)){  
        document.getElementById("lxr").style.display="block"; 
        //alert("姓名格式不符合要求");
        return false;  
     } document.getElementById("lxr").style.display="none"; 
     return true;
            }

function checkPhone(){ //验证手机号
    var phone = document.getElementById('lxdh').value;
    if(!(/^1[3456789]d{9}$/.test(phone))){ 
        document.getElementById("sjh").style.display="block"; 
         // alert("手机号格式不符合要求");
        return false; 
    } document.getElementById("sjh").style.display="none";  
    return true; 
}
原文地址:https://www.cnblogs.com/llhhcc/p/12841289.html