邮箱和电话验证

<style type="text/css">
body{
    line-height:25px;
    }
input{
    width:120px;
    height:16px;
    }
div{
    color:#F00;
    font-size:12px;
    }
</style>
<script type="text/javascript">
function checkCode(){
    var code=document.getElementById("code").value;
    var codeId=document.getElementById("code_prompt");
    var regCode=/^\d{6}$/;
    if(regCode.test(code)==false){
        codeId.innerHTML="邮政编码不正确,请重新输入";
        return false;
        }
        codeId.innerHTML="";
        return true;s
    }
function checkMobile(){
    var mobile=document.getElementById("mobile").value;
    var mobileId=document.getElementById("mobile_prompt");
    var regMobile=/^1\d{10}$/;
    if(regMobile.test(mobile)==false){
        mobileId.innerHTML="手机号码不正确,请重新输入";
        return false;
        }
        mobileId.innerHTML="";
        return true;
    }
</script>
</head>

<body>
<div id="code_prompt"></div>
<p>&nbsp;</p>
<table width="200" border="0">
  <tr>
    <td>邮政编码:</td>
    <td><input id="code" type="text" onblur="checkCode()"/></td>
  </tr>
  <tr>
    <td>手机号码:</td>
    <td><input id="mobile" type="text" onblur="checkMobile()" /></td>
  </tr>
</table>
<p>&nbsp; </p>
<div id="mobile_prompt"></div>
</body>

 

posted @ 2013-11-21 08:17  914556495  阅读(291)  评论(0编辑  收藏  举报