【问题标题】:djNumberTextBox Validation in XPagesXPages 中的 djNumberTextBox 验证
【发布时间】:2016-06-28 06:41:45
【问题描述】:

我无法验证 djNumberTextBox 类型的字段。我需要知道该字段具有值。 我在下面尝试了这个,但我无法管理该字段是否为空。

//var cFld = dijit.byId("#{id:Total}");
var aFld = dojo.byId("#{id:Total}");
if (aFld!= "")
{
    alert("Please fill the field");
    return false;
}

【问题讨论】:

    标签: validation xpages client-side


    【解决方案1】:

    你的代码对我有用。

    但是,最好使用 djNumberTextBox 控件的属性required="true" 并将消息文本设置为dojoAttribute:

    <xe:djNumberTextBox
        id="Total"
        value="#{sessionScope.test}"
        required="true">
        <xe:this.dojoAttributes>
            <xp:dojoAttribute
                name="missingMessage"
                value="Please fill the field!" />
        </xe:this.dojoAttributes>
    </xe:djNumberTextBox>
    

    它在客户端测试值并显示消息“请填写该字段!”如果值为空。您会在输入字段旁边看到这样的消息,而不是丑陋的警报框:

    【讨论】:

    • 谢谢它很好用。我对 CSJS 中的字段进行了所有验证。这就是我问的:)但是你的答案看起来更好:))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    相关资源
    最近更新 更多