// 验证邮箱函数,正确返回 true,错误返回false function validateEmail(email) { //验证邮箱正则 var re = /^(([^()[\]\\.,;:\[email protected]\"]+(\.[^()[\]\\.,;:\[email protected]\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } document.write(validateEmail(‘[email protected]‘));//返回true document.write("<br>"); document.write(validateEmail(‘123‘));//返回false
时间: 2024-12-16 14:24:08