检测邮箱输入代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>检查是否是邮箱</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
<form>
<label>邮箱:</label><input type="text" onkeyup="email(this)">
</form>
<script>
function email (argument) {
var aa=argument.value;
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9][email protected]([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(!myreg.test(aa)){
alert("邮箱输入不合法");
}
// body...
}
</script>
</body>
</html>
时间: 2024-10-20 13:01:43