1
0
Fork 0
php-coding/6.work2.php

26 lines
648 B
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>关键字标记测试</title>
</head>
<body>
<form>
<label for="email1">电子邮箱地址:</label>
<input type="text" name="email" id="email1" required onblur="checkEmailFormat()">
</form>
<script>
function checkEmailFormat(){
var mail = document.getElementById('email1').value.trim();
if(mail.length===0){
return;
}
var regex = /^\S+@([a-zA-Z0-9\-])+(\.[a-zA-Z0-9-]+)+$/;
if(regex.test(mail)){
alert('匹配');
}else {
alert('不匹配');
}
}
</script>
</body>