Form's input type=“submit” does not seem to trigger the onsubmit handler

Jdee

New Member
I am attempting to trigger a javascript function via onsubmit to validate my form.I know that the function itself works because I can call it within script tags immediately after the form's markup and I receive my console.log message and the error messages it creates appear on the form.The PHP validation itself works, but I've only been able to actually submit the form via javascript's \[code\].submit\[/code\] placed upon a div. Obviously because this bypasses any client-side validation, I can't leave it that way, thus I've replaced my div \[code\]id="submit"\[/code\] with an \[code\]input type="submit"\[/code\].I've been looking at other examples, including forms I've coded myself in the past that I know work, and seem completely out of answers. This is probably insanely easy, and for some reason, I just can't and haven't been able to see it for the last 6 hours. o_OHere is my form's markup:\[code\]<form name="emailus" id="emailus" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return validateForm();"> <a href="mailto:[email protected]"> <h3><i class="icon-envelope-alt icon-large"></i>Send us an email<span>: [email protected]</span></h3> </a> <div class="half"> <fieldset class="name"> <label for="cf_name"><h4>Name <span>*</span></h4></label> <input type="text" name="cf_name" class="textualformfield" alt="Jane Doe" pattern="^[a-zA-Z'\s]+$"> </fieldset> <fieldset class="emailaddress"> <label for="cf_email"><h4>E-mail <span>*</span></h4></label> <input type="text" name="cf_email" class="textualformfield" alt="[email protected]" pattern="{long string of regex}"> </fieldset> <fieldset class="phonenumber"> <label for="cf_phonenumber"><h4>Phone</h4></label> <input type="tel" name="cf_phonenumber" class="textualformfield" alt="555-555-5555"> </fieldset> <fieldset class="eventdate"> <label for="cf_eventdate"><h4>Event Date</h4></label> <input type="text" name="cf_eventdate" class="textualformfield" alt="May 25th, 2012"> </fieldset> <fieldset class="location"> <label for="cf_location"><h4>Location</h4></label> <input type="text" name="cf_location" class="textualformfield" alt="The Church"> </fieldset> </div> <div class="half"> <textarea name="cf_message" class="textualformfield" alt="Your Message"></textarea> </div> <input type="submit" for="emailus" name="submit" id="submit" value="http://stackoverflow.com/questions/15520057/Submit"></form>\[/code\]I've attempted several different iterations of \[code\]onsubmit="return validateForm();"\[/code\]
 
Back
Top