ok, I am working on an assignment (yes, school work) we are just being introduced to javascript. I have a contact page that I am trying to create an alert if the user tries to submit form without entering an email address. but it is not working. I have been staring at this for over an hour and can not find the problem. I am an online student and my teacher has not responded to my emails and this is due tonight. Can someone take a look and let me know if you can see my problem?
Code:<!DOCTYPE html> <html lang="en"> <head> <title>Contact</title> <meta charset="utf-8"> <link rel="stylesheet" href="fishcreek.css"> <script type="text/javascript"> <!-- function validateForm() { if (document.forms[0].myEmail.value = = " " ) { alert("Please enter an email address."); return false; } //end if return true; } // end function validateForm // --> </script> </head> <body> <div id="wrapper"> <h1 id="header"><img src="fishcreeklogo.gif" height="77" width="600" alt="Fish Creek Animal Hospital"></h1> <div class="nav" id="leftcolumn"> <ul> <li><a href="index.html">Home</a></li> <li><a href="services.html">Services</a><li> <li><a href="askvet.html">Ask the Vet</a><li> <li><a href="contact.html">Contact</a><li> </ul></div> <br> <div id="rightcolumn"> <h2>Contact Fish Creek</h2> <form method="post" action="http://webdevbasics.net/scripts/fishcreek.php" onsubmit="return validateForm();"> <label for="myName">Name: </label><input type="text" name="myName" id="myName"> <label for="myEmail">E-mail:</label> <input type="text" name="myEmail" id="myEmail"> <label for="myComments">Comments: </label> <textarea name="myComments" id="MyComments" rows="2" cols="20"></textarea> <input id="mySubmit" type="submit" value="Send Now"> <br></form> <div ID= "footer"><div class="nav"> <a href="index.html">Home</a> <a href="services.html">Services</a> <a href="askvet.html">Ask the Vet</a> <a href="contact.html">Contact</a><br> Copyright © 2013 Fish Creek Animal Hospital</div> <a href="mailto:magda@patel.com">Magda@Patel.com</a></div></div></div> </body> </html>


Reply With Quote


Bookmarks