我正在编写一个小型的HTML5网页,要求用户输入评论和电子邮件地址。如果他们没有输入评论或电子邮件,将通过JavaScript提示他们修正输入。我的问题是JavaScript根本不起作用。我认为它被完全跳过了。请告诉我哪里出错了...
<!DOCTYPE HTML>
<html lang="en-US">
<link rel="icon" type="image/png" href="img/favicon.png">
<link rel="stylesheet" type="text/css" href="css/new.css">
<title>Comments</title>
</head>
<body>
<nav id="navbar"> Navigation:
<table><tr>
<td><a href="bio.html">Bio</a></td>
<td><a href="resume.html">Resume</a></td>
<td><a href="classes.html">Classes</a></td>
<td><a href="new.html">New</a></td>
</tr></table>
</nav>
<header>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript>
function yay () {
if (document.poop.melon.value == "" || document.poop.melon.value == "Type comment here!" || document.poop.melon.value == "..." )
{
alert ( "Fill in the comment box you poopyhead!" );
document.poop.melon.value = "Type comment here!";
return false;
}
if (document.poop.maplestory.value == "youremail@mail.com" || document.poop.maplestory.value == "" || maplestory (document.poop.maplestory.value)){
alert ("Dear Sir or Madam, please type in your e-mail address.");
return false;
}
return true;
}
function maplestory( yummy )
{
var regex = /^[AZ09._%+]+@[AZ09.]+\.[AZ]{2,4}$/i;
if( yummy.search( regex ) == -1 )
return true ;
return false ;
}
</script>