郵箱驗證,郵箱驗證網站
今天看了一段代碼,是關於郵箱的驗證的,怕自己忘記了,就寫了一下,和大家分享一下
<!DOCTYPE html><html><head><meta charset="utf-8"><title></title><script>window.onload = function() {}function dianjishijian() {var x = document.getElementById("youxiang").value;var atpos = x.indexOf("@");var dotpos = x.lastIndexOf(".");if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {alert("請輸入正確的郵箱地址");return false;}}</script></head><body><input type="text" name="youxiang" id="youxiang" value="" /><button id="" onclick="dianjishijian()">點擊試試</button></body></html>
Regex怎驗證郵箱
^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$
Regex驗證郵箱地址的合法性
/^(([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]
/^(([a-zA-Z0-9_-])是表示 @ 符號之前的字串是由 小寫字母、大寫字母、數字、底線、中劃線多個字元組成字串
([a-zA-Z0-9_-])是表示@ 符號之後的字串是由 小寫字母、大寫字母、數字、底線、中劃線多個字元組成字串
\.[a-zA-Z0-9_-] 表示由小黑點和小寫字母、大寫字母、數字、底線、中劃線多個字元組成字串
/^表示多個