JSFiddle - React, Tailwind, and code Playground
by dmachi
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css">
<body class="claro">
<form dojotype="dijit.form.Form" id="regForm" action="/echo/json/">
<label>Agree</label><input dojoType="dijit.form.CheckBox" id="agree"/><br>
<input name="blah" dojoType="dijit.form.TextBox" value="foo" /><br>
<button type="submit" dojoType="dijit.form.Button">Submit</button>
</form>
</body>
JavaScript
dojo.require("dijit.form.Form");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
function sendForm() {
var form = dijit.byId("regForm");
dojo.connect(form, "onSubmit", function(event) {
event.preventDefault();
if (form.isValid()) {
if (dijit.byId('agree').get('checked')) {
var xhrArgs = {
form: "regForm",
handleAs: "text",
load: function(data) {
console.log("Success");
},
error: function(error) {
console.error("error submitting form: ", error);
} //closes error: function(error)
} //closes var xhrArgs
var deferred = dojo.xhrPost(xhrArgs);
} else {
alert("You must agree to the Terms first");
}
} else {
alert("Sorry, you must fill out every field");
}
});
};
dojo.addOnLoad(sendForm);