1. 程式人生 > >正則表達式驗證問題

正則表達式驗證問題

郵箱 .exe 大寫 a-z true orm demo exec tex

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

正則表達式驗證問題