When does this showMessage will be shown . I have written a small program please tell me why this showmessage is not shown and if shown where it will be shown ??
<html>
<head>
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
<script>
dojo.require("dijit.form.DateTextBox");
</script>
<script>
function callMe()
{
if(dijit.byId("fromDate_out").isValid())
showMessage("Selected date is fine.");
else
showMessage("Not Valid");
}
</script>
</head>
<body class="claro">
<div dojoType="dijit.form.DateTextBox" require="tru开发者_开发技巧e" id="fromDate_out" placeHolder="From Date" onChange="dijit.byId('fromDate').constraints.max =arguments[0];" ></div>
<input type="button" onclick="callMe()"/>
</body>
</html>
Make sure that you fix the mistake require="true"
, it's supposed to be required="true"
.
The showMessage method will be called when you click the button. If fromDate_out does not contain a value, showMessage will be called with "Not valid" (assuming that you fixed the "require" typo above).
We do not know what showMessage is, so if you need help with it, you have to post it as well.
The above programs have lot of issues like previous comment as well as in the onChange of the component there is a reference to fromDate component that does not exist anywhere .
dijit.byId('fromDate')
isValid() is a function that returns true and false based on the data in the text box if it has a valid date based on constraints then it returns true else false. If all the errors are fixed then on entering any value whether valid or invalid showMessage will be called on clicking the button
精彩评论