📄 validateemail.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>
testJavaScript
</title>
</head>
<body>
<script lang="JavaScript">
<!--
function test(){
var flag=true;
var field=document.forms.form1.email.value;
if (field.length<5) flag=false;
at_location=field.indexOf("@");
dot_location=field.indexOf(".");
if (at_location == -1 || dot_location==-1 || at_location>dot_location) flag=false;
if (at_location==0) flag=false;
if (dot_location-at_location<=1) flag=false;
if (field.length-dot_location<=1) flag=false;
if (!flag) alert("Email is wrong");
else alert("Good");
return false;
}
-->
</script>
<form name="form1" action="http://localhost:8080/TestHtml/a.jsp" method="post" onSubmit="return test()">
Email:<input type="text" name="email">
<input type="submit" value="Submit">
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -