CustomValidator

2 posts, 0 answers
  1. Kjell
    Kjell avatar
    203 posts
    Member since:
    May 2011

    Posted 04 Jun 2014 Link to this post

    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?












  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jun 2014 in reply to Kjell Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top