小弟我靠着W3S自学javascript
遇到问题 但周遭却苦无同好可以讨论
希望前辈们能给予指点或提示
有段程式我不太明白它的意思,程式取自以下网址
http://www.w3school.com.cn/js/js_form_validation.asp
红色部分是我看不懂的地方,先谢过各位前辈 <(_ _)>
<html>
<head>
<script type="text/javascript">
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false}
else {return true}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address!")==false)
{email.focus();return false}
}
}
</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>
</html>