CustomValidator not adding error to ValidationSummary

Discussion in 'ASP .Net' started by Guest, Aug 21, 2005.

  1. Guest

    Guest Guest

    We want to require a value for CboCharity if the value for cboCardSource =
    Fundraiser. Here's the client script:

    <script language="javascript">
    <!--
    function ValidateCharity(source, arguments)
    {
    frmRegister.cboCardSource.IsValid = true;
    if (frmRegister.cboCardSource.value == "Fundraiser")
    {
    if (frmRegister.cboCharity.value == "")
    {
    frmRegister.cboCardSource.IsValid = false;
    }
    }
    }

    //-->
    </script>

    Here's the CustomValidator:

    <asp:customvalidator id="valFundraiser" runat="server"
    ErrorMessage="A Fundraiser must be selected" Font-Size="X-Small"
    Font-Names="Arial" ControlToValidate="cboCardSource"
    ClientValidationFunction="ValidateCharity" Display="None">
    </asp:customvalidator>

    When the value of cboCardSource = "Fundrasier" and the value of cboCharity =
    "" the ValidateCharity client script function runs and cboCardSource.IsValid
    is set to false, however the validation summary never includes the error for
    cboCardSource: "A Fundraiser must be selected". Why?
     
    Guest, Aug 21, 2005
    #1
    1. Advertisements

  2. Guest

    Peter Blum Guest

    The arguments parameter contains the IsValid property to set to true or
    false. You are setting IsValid on the validator, not arguments.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx
     
    Peter Blum, Aug 22, 2005
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.