电话号码正则表达式

前端之家收集整理的这篇文章主要介绍了电话号码正则表达式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<html>
<head>
	<script>
		function thisCheck(){
			var value = document.getElementById("text").value
			var reg1 = /^[1][3,5,8]\d{9}$/;  //11位号码的
			var  reg2 = /^\d{7,8}$/;         //电话号码
			var reg3 = /^(\d{4}|\d{3})-(\d{7,8}$)/     //; 带区号的
			var  reg4 = /^\d{3,5}$/;        //短号
			var reg5 = /^(\d{4}|\d{3})-(\d{7,8})-(\d{4})$/;
//			var reg = new RegExp("/(^[1][3,8]\d{9}$) | (^\d{7,8}$) | (^(\d{4}|\d{3})-(\d{7,8}$) | (^\d{3,5}$) | (^(\d{4}|\d{3})-(\d{7,8})-(\d{4})$)/");
			var me = false;    	
			if(reg1.test(value))  {  
				me = true;
			}  else{
				me=false;
			}	
			alert(me);			
		}
	</script>
</head>

<body>
	<input type ='text' id = 'text' />
	<input type ='button' value = '测试' onclick = 'thisCheck()'/>
	<br>支持<br>025-4691936-56892<br>0215-4691936-56892<br>110<br>96669<br>5230<br>手机号码<br>4691936<br>469193698<br>025-4691936<br>025-46919361
		
</body>
</html>

猜你在找的正则表达式相关文章