ShaolinF Posted October 14, 2007 Share Posted October 14, 2007 Hi guys, Im trying to use div tags to check my form fields. The problem is when I submit it doesn't do anything. See code: <form action="continue.php" name="signup" method="post" onsubmit="return toggleDiv(this);"> <p><label for="name">Your Name:</label><br /> <input type="text" name="name" size="26" /><br /> <br /> <label for="contact">Your Contact No:</label><br /> <input type="text" name="contact" size="26" /><br /> <br /> <label for="email">Your Email:</label><br /> <input type="text" name="email" size="26" /><br /> <br /> <input type="radio" name="sex" value="Male" class="radioStyle" /> Male <input type="radio" name="sex" value="Female" class="radioStyle" /> Female<br /> <br /> <input type="reset" class="altButtonFormat" /> <input type="submit" value="Continue >>" class="altButtonFormat" /></p> </form> <script language="javascript"> function toggleDiv(signup){ if(signup.name.value == "") { document.getElementById(mydiv).style.display = 'block'; return false; } } </script> <div id="mydiv" style="display:none"><h3>This is a test!<br>Can you see me?</h3></div> Quote Link to comment Share on other sites More sharing options...
mainewoods Posted October 14, 2007 Share Posted October 14, 2007 function toggleDiv(signup){ if(signup.name.value == "") { document.getElementById(mydiv).style.display = 'block'; return false; } } --the 'mydiv' above must have quotes around it or javascript will interpret it as a variable that is undefined. Use: document.getElementById('mydiv').style.display = 'block'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.