當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

檢查電話號碼的正確性

檢查電話號碼的正確性

更新時間:2019-05-25 文章作者:未知 信息來源:網絡 閱讀次數:


在這里只能入數字和()-+四個字符,這樣對輸入的電話號碼起到了一定的檢查. 請輸入電話號碼:在<head>...</head>之間加入如下代碼: 
<script LANGUAGE="javascript">
<!--
function check()
{
if (document.form.tell.value==""){
  alert("請輸入電話號碼!");
  document.form.tell.focus();
  return false;
}
else{
  var Letters = "0123456789()+-";
  for (i=0; i< document.form.tell.value.length; i++){
     var CheckChar = document.form.tell.value.charAt(i);
     if (Letters.indexOf(CheckChar) == -1){
       alert("電話號碼格式不正確!");
       document.form.tell.focus();
       return false;
      }
    }
  }
}
//-->
</script> 在<body>...</body>之間的表單.
<form method="POST" name=form action="" onSubmit="return check();">
<p align="center">
   請輸入電話號碼:<input type="text" name="tell" size="20">
<input type="submit" value="提交" name="B1"></p>
</form>

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
亚洲嫩草影院久久精品