This is a migrated thread and some comments may be shown as answers.

CustomValidator

1 Answer 337 Views
Input
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Iron
Kjell asked on 04 Jun 2014, 10:23 AM
I have try to use CustomValidator with telerik:RadTextBox but it is not fired?

​<telerik:RadTextBox ID="rtbTelefon" MaxLength="50" Width="220px" EmptyMessage="Telefon" ToolTip="Telefon" runat="server" /><telerik:RadTextBox ID="rtbEpost" MaxLength="50" Width="230px" EmptyMessage="E-postadress" ToolTip="E-postadress" runat="server" /> <asp:CustomValidatorid="AtLeastOneContact" ClientValidationFunction="AtLeastOne_ClientValidate"Display="None" ErrorMessage="Telefon <b>eller</b> e-post krävs!"   SetFocusOnError="True"runat="server" />


And in telerik:RadScriptBlock
function AtLeastOne_ClientValidate(source, args) {
    if (document.getElementById("<%= rtbTelefon.ClientID %>").value == "" &&
        document.getElementById("<%= rtbEpost.ClientID %>").value == "") {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


Nothing happand, but if i change to <asp:TextBox it works??
Why does it not work with telerik:RadTextBox?












1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Jun 2014, 04:07 AM
Hi Kjell,

Please do the following modification in your JavaScript which works fine at my end.

JavaScript:
function AtLeastOne_ClientValidate(source, args) {
    if ($find("<%=rtbTelefon.ClientID %>")._text == "" && $find("<%=rtbEpost.ClientID %>")._text == "") {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

Thanks,
Shinu.
Tags
Input
Asked by
Kjell
Top achievements
Rank 1
Iron
Answers by
Shinu
Top achievements
Rank 2
Share this question
or