麻烦大神在里面添加一个判断邮箱格式是否正确的代码(新人学习javascript拜托大神帮帮忙)
<script>function formcheck()
{
var name=document.getElementById("userid").value;
var password=document.getElementById("pass").value;
var dotpos=document.getElementById("Y").value;
if(name=="")
{ alert("学号不能为空");
return false;
}
else if(name.length!=10)
{alert("学号长度不对");
return false;
}
if(password=="")
{
alert("密码不能为空");
return false;
}
if(dotpos=="")
{alert("邮箱不能为空");
return false;}
document.getElementById("form1").submit();
}
</script>
</head>
<body><form id="form1" name="form1" method="post" action="" onsubmit="return formcheck">
<p>
<label for="textfield">学号</label>
<input type="text" name="textfield" id="userid" />
</p>
<p>
<label for="textfield2">密码</label>
<input type="text" name="textfield2" id="pass" />
</p>
<p>
<label for="textfield3">邮箱</label>
<input type="text" name="textfield3" id="Y" />
</p>
<p>
<input type="button" name="button" id="button" value="提交" onclick="formcheck()"/>
</p>
</form>
</body>
</html>