2014-08-27 62 views
0

问题: -

我使用以下使用工具提示示出的错误消息的HTML代码每当教科书长度等于零, 但我无法设置我定义的工具尖端内部消息。
如何显示dojo验证错误工具提示?

<body class="claro"> 
    <form action=""> 


    Enter Name:-- 
    <input type="text" name="firstname" data-dojo-props="" data-dojo-type="dijit.form.TextBox" 
    trim="true" id="firstname" propercase="true"> 
    <button id="button4" data-dojo-type="dijit.form.Button" type="button">Submit 
     <script type="dojo/method" event="onClick" args="newValue"> 
    alert("Value selected is: "+newValue); 
      var firstNameId=dijit.byId("firstname").value; 
    alert('firstNameId.length:----'+firstNameId.length); 

    if(firstNameId.length==0) 
    { 
    var textBox = dijit.byId("firstname"); 
    dijit.showTooltip(
     textBox.get("invalidMessage"), 
     textBox.domNode, 
     textBox.get("justMessage"), 
     !textBox.isLeftToRight() 
    ); 
    } 
    else 
    { 
    alert('wrong'); 
    ); 
    } 

    <br> 

帮我出....

回答

0

这已经有一段时间,因为你张贴了这个问题,但如果你仍然需要它,这里有一个答案。

Dijit/form/TextBox没有showTooltip方法。要显示一个提示,你可以改为调用类似:

var textBox = dijit.byId("firstname"); 

textBox.invalidMessage = "Whatever you want"; 

Tooltip.show(textBox.get("invalidMessage"), 
      textBox.domNode, textBox.get("tooltipPosition"), 
      !textBox.isLeftToRight()); 

一定要包括的dijit /工具提示!

相关问题