Custom validator for a pair of controls

Discussion in 'ASP .Net Web Controls' started by Erik Cruz, Jul 17, 2004.

  1. Erik Cruz

    Erik Cruz Guest

    Hi.

    I have a page that uses 4 textboxes where my user can input dates. Before
    submit data, I need to test to see if the user filled at least two of these
    textboxes. I can easily test this using simple javascript, but I am trying
    to do this using a custom validator control. But as far as I know, the
    validator tests just one control, not a pair of controls, as I need. Is it
    possible to create a custom control for this situation?

    TIA,
    Erik Cruz
    Erik Cruz, Jul 17, 2004
    #1
    1. Advertising

  2. Erik Cruz

    Teemu Keiski Guest

    Hi,

    you can check multiple controls with CustomValidator. If you leave
    ControlToValidate property to blank, CustomValidator runs the server-side
    and client-side validation once per roundtrip (client-side before submitting
    and server-side while postbacking as usual). It means the CustomValidator
    isn't tied to the control and you can validate anything you want with it
    (also blank controls or conditional validation). Certainly you need to refer
    to the controls you validate in validion functions but that shouldn't be
    hard.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke

    "Erik Cruz" <> wrote in message
    news:%...
    > Hi.
    >
    > I have a page that uses 4 textboxes where my user can input dates. Before
    > submit data, I need to test to see if the user filled at least two of

    these
    > textboxes. I can easily test this using simple javascript, but I am trying
    > to do this using a custom validator control. But as far as I know, the
    > validator tests just one control, not a pair of controls, as I need. Is it
    > possible to create a custom control for this situation?
    >
    > TIA,
    > Erik Cruz
    >
    >
    Teemu Keiski, Jul 18, 2004
    #2
    1. Advertising

  3. Erik Cruz

    fritz Guest

    Teemu Keiski wrote:

    > Hi,
    >
    > you can check multiple controls with CustomValidator. If you leave
    > ControlToValidate property to blank, CustomValidator runs the server-side
    > and client-side validation once per roundtrip (client-side before
    > submitting and server-side while postbacking as usual). It means the
    > CustomValidator isn't tied to the control and you can validate anything
    > you want with it (also blank controls or conditional validation).
    > Certainly you need to refer to the controls you validate in validion
    > functions but that shouldn't be hard.
    >

    I am confused, is there not a problem with the label?. I thought the custom
    validator used a label with a specific id.
    fritz, Jul 19, 2004
    #3
  4. Erik Cruz

    Teemu Keiski Guest

    Are you somehow confusing validators that are done by using built-in
    CustomValidator and then custom validator controls which are developed by
    inheriting from BaseValidator? The built-in CustomValidator can work the way
    I described (without ControlToValidate property)

    Here is about the CustomValidator I was talking about:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp


    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke



    "fritz" <> wrote in message
    news:kWGKc.38071$...
    > Teemu Keiski wrote:
    >
    > > Hi,
    > >
    > > you can check multiple controls with CustomValidator. If you leave
    > > ControlToValidate property to blank, CustomValidator runs the

    server-side
    > > and client-side validation once per roundtrip (client-side before
    > > submitting and server-side while postbacking as usual). It means the
    > > CustomValidator isn't tied to the control and you can validate anything
    > > you want with it (also blank controls or conditional validation).
    > > Certainly you need to refer to the controls you validate in validion
    > > functions but that shouldn't be hard.
    > >

    > I am confused, is there not a problem with the label?. I thought the

    custom
    > validator used a label with a specific id.
    >
    Teemu Keiski, Jul 19, 2004
    #4
  5. Erik Cruz

    Erik Cruz Guest

    Thanks Teemu, it worked :)

    Maybe you can help me with another issue. My users type dates using the
    format DD/MM/YYYY. How can I validate these dates in server-side code,
    regardless of the format they are using?

    Thanks again for your time.

    Erik Cruz

    "Teemu Keiski" <> wrote in message
    news:%...
    > Hi,
    >
    > you can check multiple controls with CustomValidator. If you leave
    > ControlToValidate property to blank, CustomValidator runs the server-side
    > and client-side validation once per roundtrip (client-side before

    submitting
    > and server-side while postbacking as usual). It means the CustomValidator
    > isn't tied to the control and you can validate anything you want with it
    > (also blank controls or conditional validation). Certainly you need to

    refer
    > to the controls you validate in validion functions but that shouldn't be
    > hard.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    > http://blogs.aspadvice.com/joteke
    >
    > "Erik Cruz" <> wrote in message
    > news:%...
    > > Hi.
    > >
    > > I have a page that uses 4 textboxes where my user can input dates.

    Before
    > > submit data, I need to test to see if the user filled at least two of

    > these
    > > textboxes. I can easily test this using simple javascript, but I am

    trying
    > > to do this using a custom validator control. But as far as I know, the
    > > validator tests just one control, not a pair of controls, as I need. Is

    it
    > > possible to create a custom control for this situation?
    > >
    > > TIA,
    > > Erik Cruz
    > >
    > >

    >
    >
    Erik Cruz, Jul 20, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RHVuZQ==?=

    validator controls and disabled controls

    =?Utf-8?B?RHVuZQ==?=, Feb 4, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    695
    Peter Blum
    Feb 4, 2004
  2. Replies:
    0
    Views:
    351
  3. rodchar
    Replies:
    0
    Views:
    385
    rodchar
    Nov 26, 2007
  4. Zoe Hart
    Replies:
    1
    Views:
    355
    Scott Wisniewski
    Jan 8, 2004
  5. Scott Yenor

    How to get custom control to work with custom validator

    Scott Yenor, Jan 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    201
    Scott Yenor
    Jan 27, 2004
Loading...

Share This Page