许多ASPxTextBox同时验证组

时间:2013-07-01 07:36:20

标签: javascript asp.net devexpress

我正在通过正则表达式在焦点输出中验证javascript中的一些.net文本框:

ValidationExpression="[0-9]+(\.[0-9][0-9]?)?" 

所有文本框。

if isValidate,button enabled = true else button enabled = false

但我的代码不起作用:

<dx:ASPxTextBox ID="tbxAcPart" runat="server" Width="95px" ClientIDMode="Static">
    <ClientSideEvents Validation="function(s, e) {ValidTextBox(s);}" />
    <ValidationSettings ErrorDisplayMode="Text" EnableCustomValidation="true"  SetFocusOnError="true" ValidationGroup="Apply" Display="Dynamic" ErrorTextPosition="Bottom" >
     <ErrorFrameStyle Font-Size="Smaller"/>
     <RegularExpression ValidationExpression="[0-9]+(\.[0-9][0-9]?)?" ErrorText="Numeric   !" /> 
     <RequiredField IsRequired="true" />
    </ValidationSettings>
</dx:ASPxTextBox>


<dx:ASPxTextBox ID="tbxMpPart" runat="server" Width="95px" ClientIDMode="Static">
    <ClientSideEvents Validation="function(s, e) {ValidTextBox(s);}" />
    <ValidationSettings ErrorDisplayMode="Text" EnableCustomValidation="true"  SetFocusOnError="true" ValidationGroup="Apply" Display="Dynamic" ErrorTextPosition="Bottom" >
         <ErrorFrameStyle Font-Size="Smaller"/>
         <RegularExpression ValidationExpression="[0-9]+(\.[0-9][0-9]?)?" ErrorText="Numeric   !" /> 
         <RequiredField IsRequired="true" />
    </ValidationSettings>
</dx:ASPxTextBox>
function ValidTextBox(s) {
    if (s.GetIsValid()) {
        decimalErr.SetText('');
    }
    else {
        decimalErr.SetText(s.GetErrorText());
        var t = document.getElementsById("btApply");
        t.disabled = true;
        this.focus();
    }
}

1 个答案:

答案 0 :(得分:0)

如果使用服务器控件,则需要使用ctl.ClientID

function ValidTextBox(s) {

        if (s.GetIsValid()) {
            decimalErr.SetText('');
        }
        else {
            decimalErr.SetText(s.GetErrorText());
            var t = document.getElementById("<%= btApply.ClientID %>");
            t.disabled = true;
            this.focus
        }
}