首页 > 其他 > 详细

正则表达

时间:2018-10-30 22:14:29      阅读:157      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
<head>
 <title>正则表达式</title>
 <meta charset="utf-8">
 <style>
 .input{
            width: 300px;
            height: 40px;
            font: 20px/40px "";
            margin: 200px 320px;
        }
        .input1{
         
            height: 40px;
            font: 20px/40px "";
            margin: 200px -320px;
        }
    .a{
             width: 120px;
             height: 50px;
             position: relative;
             left: 300px;
             font: 30px/50px "";
         }
    </style>
    <script>
    function 检测()
 {
  var name=document.getElementsByTagName(‘name‘).value;
  var norms=/^[A-Za-z0-9]{1,6}/;
  
  if (norms.test(name))
  {
   alert("OK");
  }
  else
  {
   alert("NO");
  }
 }
 </script> 
 
</head>
<body>
 <label for="name" class="a">Name:</label>
  <input type="text" placeholder="不超过6个字符" name="name" id="name" class="input">
  <input type="button" value="检测" onclick="检测()" class="input1">
 
 
</body>
</html>
 
效果如下:
技术分享图片

 

正则表达

原文:https://www.cnblogs.com/0sakura0/p/9879945.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!