| | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| | 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| | 3 | <html> |
| | 4 | <head> |
| | 5 | <title>Test Form Validate Function</title> |
| | 6 | |
| | 7 | <style type="text/css"> |
| | 8 | @import "../../../dojo/resources/dojo.css"; |
| | 9 | @import "../css/dijitTests.css"; |
| | 10 | </style> |
| | 11 | |
| | 12 | <script type="text/javascript" src="../../../dojo/dojo.js" |
| | 13 | djConfig="isDebug: true, parseOnLoad: true, extraLocale: ['de-de', 'en-us']"></script> |
| | 14 | <script type="text/javascript" src="../_testCommon.js"></script> |
| | 15 | |
| | 16 | <script type="text/javascript"> |
| | 17 | dojo.require("dijit.form.ValidationTextBox"); |
| | 18 | dojo.require("dijit.form.DateTextBox"); |
| | 19 | dojo.require("dijit.form.Button"); |
| | 20 | |
| | 21 | dojo.require("dijit.form.Form"); |
| | 22 | dojo.require("dojo.parser"); // scan page for widgets and instantiate them |
| | 23 | </script> |
| | 24 | </head> |
| | 25 | |
| | 26 | <body> |
| | 27 | <h1 class="testTitle">Dijit Form Validation Test</h1> |
| | 28 | <form dojoType="dijit.form.Form" id="form1" action="" name="example" method=""> |
| | 29 | <table> |
| | 30 | <tr> |
| | 31 | <td><label for="name">Name:</label></td> |
| | 32 | <td><input id="name" dojoType="dijit.form.ValidationTextBox" |
| | 33 | required="true" name="name" /></td> |
| | 34 | </tr> |
| | 35 | <tr> |
| | 36 | <td><label for="birth">Birthdate (before 2006-12-31):</label></td> |
| | 37 | <td><input id="birth" dojoType="dijit.form.DateTextBox" |
| | 38 | required="true" name="birth" constraints="{max:'2006-12-31'}" /></td> |
| | 39 | </tr> |
| | 40 | <tr> |
| | 41 | <td><label for="notes">Notes (optional)</label></td> |
| | 42 | <td><input id="notes" dojoType="dijit.form.TextBox" |
| | 43 | name="notes" /></td> |
| | 44 | </tr> |
| | 45 | </table> |
| | 46 | <button dojoType="dijit.form.Button"> |
| | 47 | <script type="dojo/method" event="onClick"> |
| | 48 | if (dijit.byId("form1").validate()){ |
| | 49 | window.alert("Form is valid!"); |
| | 50 | } |
| | 51 | </script> |
| | 52 | Validate Form |
| | 53 | </button> |
| | 54 | </form> |
| | 55 | </body> |
| | 56 | </html> |