professional-javascript-11-OnSubmitExample.htm / htm
<html> <head> <title>OnSubmit Example</title> <script type="text/javascript" src="detect.js"></script> <script type="text/javascript" src="eventutil.js"></script> <script type="text/javascript"> function handleSubmit() { var oEvent = EventUtil.getEvent(); oEvent.preventDefault(); } </script> </head> <body> <form id="form1" method="post" action="javascript:alert('Submitted')" onsubmit="handleSubmit()"> <!-- regular textbox --> <label for="txtName">Name:</label><br /> <input type="text" id="txtName" name="txtName" /><br /> <!-- password textbox --> <label for="txtPassword">Password:</label><br /> <input type="password" id="txtPassword" name="txtPassword" /><br /> <!-- age comboxbox (drop-down) --> <label for="selAge">Age:</label><br /> <select name="selAge" id="selAge"> <option>18-21</option> <option>22-25</option> <option>26-29</option> <option>30-35</option> <option>Over 35</option> </select><br /> <!-- multiline textbox --> <label for="txtComments">Comments:</label><br /> <textarea rows="10" cols="50" id="txtComments" name="txtComments"></textarea><br /> <!-- custom submit button --> <input type="submit" value="Submit Form" /> </form> <p>This example blocks the form submission (you won't see an alert box).</p> </body> </html>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.