<script>
function validate_form(thisform)
{
with(thisform)
{
if(validate_email(email,"email must be filled out.")==false)
{
email.focus;
}
else
{
alert("validate successful.");
}
}
}
function validate_email(field,alerttxt)
{
with (field)
{
//验证是否为空
if (value == null || value == "")
{
alert(alerttxt);
return false;
}
else
{
//非空时,验证是否email格式
apos = value.indexOf("@");
dotpos = value.lastIndexOf(".");
if (apos < 1 || dotpos - apos < 2)
{
alert("Not a valid e-mail address!");
return false;
}
else
{
return true;
}
}
}
}
</script>
</head>
<body>
<form action="submitpage.htm" onsubmit="return validate_form(this)" method="post">
Email:
<input type="text" name="email" size="30">
<input type="submit" value="Submit">
</form>
</body>
验证Email地址是否符合格式。
本文地址:https://blog.csdn.net/weixin_49884163/article/details/107882869
如对本文有疑问, 点击进行留言回复!!
bootstrap-closable-tab可实现关闭的tab标签页插件
vue-cli单页面预渲染seo-prerender-spa-plugin操作
网友评论