2011-07-01 54 views
0

何時會顯示showMessage。我已經寫了一個小程序,請告訴我 爲什麼這個showmessage沒有顯示,如果顯示在哪裏會顯示?關於使用DOJO showMessage的查詢

<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="true" id="fromDate_out" placeHolder="From Date" onChange="dijit.byId('fromDate').constraints.max =arguments[0];" ></div> 



    <input type="button" onclick="callMe()"/> 

</body> 
</html> 

回答

0

請確保您更正此錯誤require="true",它應該是required="true"

當您單擊按鈕時,將會調用showMessage方法。如果fromDate_out不包含值,showMessage將被稱爲「無效」(假設您修正了上面的「require」錯字)。

我們不知道showMessage是什麼,所以如果你需要幫助,你也必須發佈它。

0

上述程序有很多問題,如以前的評論,以及組件的onChange有一個引用fromDate組件的任何地方都不存在。

dijit.byId('fromDate') 

的isValid()是一個基於文本框中的數據返回真假的功能,如果它具有基於約束的有效日期,那麼它返回true,否則返回false。 如果所有的錯誤都是固定的,那麼在輸入任何值時,無論showMessage是有效還是無效,點擊按鈕