打印本文 打印本文 关闭窗口 关闭窗口
判断一段字符中是否含有电话号码的方法
作者:武汉SEO闵涛  文章来源:敏韬网  点击数805  更新时间:2009/4/23 11:27:40  文章录入:mintao  责任编辑:mintao

<script LANGUAGE="javascript">
<!--
function checkNum(str){return !/\d{6}/.test(str)}
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>

<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>

打印本文 打印本文 关闭窗口 关闭窗口