<html>
<head>
<script language="javascript">
function verifyAddress(obj)
{
// obtain form value into variable
var email = obj.value;
alert ('email' + email);
// define regex
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
// test for pattern
flag = pattern.test(email);
if(flag)
{
alert("Right e-mail format!");
return true;
}
else
{
alert("Wrong e-mail format!");
return false;
}
}
</script>
</head>
<body>
<form>
<input name="mail" type="text" onBlur="return verifyAddress(this);">
<input type="submit">
</form>
</body>
</html>
全站熱搜
留言列表