<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>Document</title>
 </head>
 <body>
  <script>
		function testReg(){
			var regExp = /^\d{2,6}$/g;
			var input = prompt("请输入2-6位的数字:");
			if(regExp.test(input)){
				alert("格式正确");
			}else{
				alert("格式错误");
			}
		}
	</script>
	<button onclick="testReg()">测试正则表达式</button>
 </body>
</html>

JS-regExp-正则表达式匹配2-6的数字

相关文章:

  • 2021-07-26
  • 2022-12-23
  • 2021-04-20
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
猜你喜欢
  • 2021-10-10
  • 2021-08-01
  • 2022-12-23
  • 2022-01-11
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案