正则表达式验证问题

<!DOCTYPE html>
<html>
<body>

<p>用户名正则表达式 ,4到16位(字母,数字,下滑线,减号)</p>
<p id="demo"></p>
<form action="" method="get">
  <p>用户名: <input type="text" name="fname" required></p>
  <button onclick="myFunction1()">疯狂点我</button>
  <p>密码强度,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符</p>
  <p>密码: <input type="password" name="lname" required></p>
   <button onclick="myFunction()">疯狂点我</button>
   <p>邮箱 <input type="text" name="lname" required></p>
   <button onclick="myFunction()">疯狂点我</button>
   <p>身份证 <input type="text" name="lname" required></p>
</form>

<script>
function myFunction1() {
    var patrn=/^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,16}$/;   
if (!patrn.exec(s)) return false
return true
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

猜你喜欢

转载自www.cnblogs.com/mumu597/p/9873961.html