javascript - Can't cllick submit button -
i'm newb trying learn create form page. can tell me why submit button isn't working? thought having javascript function fix this. thanks
<script type="text/javascript"> function submitform() { document.forms["contactform"].submit(); }
</head> <body> <div id="contact-form"> <form method="post" id="contactform" action="bespoke-form-handler.php"> <div> <label for="name">name:</label> <input type="text" id="name" name="user_name" /> </div> <div> <label for="mail">e-mail:</label> <input type="email" id="mail" name="user_email" /> </div> <div class="button"> <button type="submit" name="submit"><a href="javascript: submitform()">submit</a></button> </div> </form> <script language="javascript"> var frmvalidator = new validator("contactform"); frmvalidator.addvalidation("name","req","please provide name"); frmvalidator.addvalidation("mail","req","please provide email"); frmvalidator.addvalidation("mail","email","please enter valid email address"); </script> </body>
the problem button name, since have used submit
, document.forms["contactform"].submit
refer element not submit method cause error uncaught typeerror: document.forms.contactform.submit not function
<button type="submit" name="someothername"><a href="javascript: submitform()">submit</a></button>
Comments
Post a Comment