Debian Codegraph @

dijit/tests/form/test_Form_state.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>dijit.form.Form Valid/Invalid State Test</title>
6
7 <style type="text/css">
8 @import "../../themes/claro/document.css";
9 @import "../css/dijitTests.css";
10 </style>
11
12 <!-- required: the default dijit theme: -->
13 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
14
15 <!-- required: dojo.js -->
16 <script type="text/javascript" src="../../../dojo/dojo.js"
17 data-dojo-config="isDebug: true, parseOnLoad: true, extraLocale: ['de-de', 'en-us']"></script>
18
19 <!-- only needed for alternate theme testing: -->
20 <script type="text/javascript" src="../_testCommon.js"></script>
21
22 <script type="text/javascript">
23 dojo.require("dijit.form.ValidationTextBox");
24 dojo.require("dijit.form.DateTextBox");
25 dojo.require("dijit.form.Button");
26 dojo.require("dijit.form.FilteringSelect");
27 dojo.require("dijit.form.Form");
28 dojo.require("dojo.parser"); // scan page for widgets and instantiate them
29 </script>
30 </head>
31
32 <body class="claro" role="main">
33 <h1 class="testTitle">dijit.form.Form Valid/Invalid State Test</h1>
34 <p>
35 Tests that dijit.form.Form correctly changes state from valid to invalid (as indicated by disabled/enabled submit button)
36 according to child widget state.
37 </p>
38 <form id="form1" data-dojo-type="dijit/form/Form" data-dojo-props='action:"", name:"example", method:""'>
39 <script type="dojo/connect" data-dojo-event="startup">
40 var submitButton = dijit.byId("submitButton");
41 // set initial state
42 submitButton.set("disabled", !this.isValid());
43 this.connect(this, "onValidStateChange", function(state){
44 submitButton.set("disabled", !state);
45 });
46 </script>
47 <table role="presentation">
48 <tr>
49 <td><label for="name">Name:</label></td>
50 <td><input id="name" data-dojo-type="dijit/form/ValidationTextBox"
51 data-dojo-props='required:true, name:"name" '/></td>
52 </tr>
53 <tr id="newRow" style="display: none;">
54 <td><label for="lastName">Last Name:</label></td>
55 <td><input id="lastName" /></td>
56 </tr>
57 <tr>
58 <td><label for="birth">Birthdate (before 2006-12-31):</label><br><br><br><br></td>
59 <td><div><input id="birth" data-dojo-type="dijit/form/DateTextBox" data-dojo-props='value:"2000-01-01",
60 required:true, name:"birth", constraints:{min:"1900-01-01", max:"2006-12-31"} '/> <br>
61 <button id="disable" onclick="dijit.byId('birth').set('disabled',true);return false;">Disable</button>
62 <button id="enable" onclick="dijit.byId('birth').set('disabled',false);return false;">Enable</button>
63 <button id="reset" onclick="dijit.byId('birth').reset();return false">Reset</button> <br><br>
64 </div></td>
65 </tr>
66 <tr>
67 <td><label for="notes">Notes (optional)</label></td>
68 <td><input id="notes" data-dojo-type="dijit/form/TextBox"
69 data-dojo-props='name:"notes" '/></td>
70 </tr>
71 <tr id="newRow2" style="display: none;">
72 <td><label for="color">Favorite Color</label></td>
73 <td><select id="color">
74 <option value="red">Red</option>
75 <option value="yellow">Yellow</option>
76 <option value="blue">Blue</option>
77 </select></td>
78 </tr>
79 </table>
80 <button id="submitButton" data-dojo-type="dijit/form/Button" >
81 <script type="dojo/method" data-dojo-event="onClick">
82 console.dir(dijit.byId("form1").get('value'));
83 </script>
84 Submit
85 </button>
86 <button id="addMoreFields" data-dojo-type="dijit/form/Button" >
87 <script type="dojo/method" data-dojo-event="onClick">
88 new dijit.form.FilteringSelect({id: "color",
89 name: "color",
90 required: true},
91 dojo.byId("color"));
92 new dijit.form.ValidationTextBox({id: "lastName",
93 name: "lastName",
94 required: true},
95 dojo.byId("lastName"));
96 dojo.byId("newRow").style.display = "";
97 dojo.byId("newRow2").style.display = "";
98 this.set("disabled", true);
99 this.domNode.blur();
100 // Call this, since we added a new widget - so that our
101 // form knows that we have something else to watch.
102 dijit.byId("form1").connectChildren();
103 </script>
104 Add More Fields
105 </button>
106 <button data-dojo-type="dijit/form/Button">
107 <script type="dojo/method" data-dojo-event="onClick">
108 dijit.byId("name").validate();
109 </script>
110 validate
111 </button>
112 </form>
113 </body>
114 </html>