1. 程式人生 > >郵箱驗證登錄

郵箱驗證登錄

-m document set php submit scrip mit ext tex

--------------------------------------------------------------------------------------------------------------------

<%@ page pageEncoding="utf-8"%>
<html>
<head>
<meta charset="utf-8">
<title>郵箱登錄判斷</title>
</head>
<head>
<script>
function validateForm(){
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length){
alert("不是一個有效的 e-mail 地址");
return false;
}
}
</script>
</head>
<body>

<form name="myForm" action="demo-form.php" onsubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="提交">
</form>

</body>
</html>

郵箱驗證登錄