//強弱密碼校驗,密碼至少包含大寫字母,小寫字母,數字,且不少於8位 var tx = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/; var pass = 'aaaa12345' if(!tx.test(pass)){ alert("弱密碼"); }els ...
//強弱密碼校驗,密碼至少包含大寫字母,小寫字母,數字,且不少於8位 var tx = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/; var pass = 'aaaa12345' if(!tx.test(pass)){ alert("弱密碼"); }else{ alert("強密碼") } //郵箱格式校驗
var email = '2222@'; var mailReg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"); if (!mailReg.test(email)) { //正則驗證不通過,格式不對 alert("請輸入正確的郵箱地址!"); }