Help: Requiredfield validator

Discussion in 'ASP .Net Web Controls' started by Sean, Jul 31, 2003.

  1. Sean

    Sean Guest

    Hi,

    I have 2 buttons A and B, textbox C and dropdown list D. When A is clicked,
    C is required field. When B is clicked, C and D are required fields. There
    is a dummy entry "please select" in the dropdown list. When B is clicked, D
    can't be the dummy option.

    I wonder what is the best practice for this case? I was thinking to use
    server-side validation for these controls, and created 2 RequiredField
    Validators and set them TRUE at designer. Is there anybody who can enlighten
    me? Thanks.
     
    Sean, Jul 31, 2003
    #1
    1. Advertising

  2. Re: Requiredfield validator

    Sean:

    I would use a CustomValidator for this. Using JavaScript its really easy to
    detect if the first item in the dropdown box is selected.

    Something like:

    function isFirstPicked()
    {
    if (document.formname.dropdownlistname.selectedIndex == 0)
    {
    return false;
    }
    }

    tie the function into your CustomValidator and you should be good to go.

    HTH
    --
    Elliot M. Rodriguez, MCSD
    *** It would take 227 cans of Mountain Dew to kill me***



    "Sean" <> wrote in message
    news:OF3o%...
    > Hi,
    >
    > I have 2 buttons A and B, textbox C and dropdown list D. When A is

    clicked,
    > C is required field. When B is clicked, C and D are required fields. There
    > is a dummy entry "please select" in the dropdown list. When B is clicked,

    D
    > can't be the dummy option.
    >
    > I wonder what is the best practice for this case? I was thinking to use
    > server-side validation for these controls, and created 2 RequiredField
    > Validators and set them TRUE at designer. Is there anybody who can

    enlighten
    > me? Thanks.
    >
    >
    >
     
    Elliot Rodriguez, Jul 31, 2003
    #2
    1. Advertising

  3. Sean

    Sean Guest

    Re: Requiredfield validator

    I got the idea. Thank you.

    "Elliot Rodriguez" <> wrote in message
    news:#...
    > Sean:
    >
    > I would use a CustomValidator for this. Using JavaScript its really easy

    to
    > detect if the first item in the dropdown box is selected.
    >
    > Something like:
    >
    > function isFirstPicked()
    > {
    > if (document.formname.dropdownlistname.selectedIndex == 0)
    > {
    > return false;
    > }
    > }
    >
    > tie the function into your CustomValidator and you should be good to go.
    >
    > HTH
    > --
    > Elliot M. Rodriguez, MCSD
    > *** It would take 227 cans of Mountain Dew to kill me***
    >
    >
    >
    > "Sean" <> wrote in message
    > news:OF3o%...
    > > Hi,
    > >
    > > I have 2 buttons A and B, textbox C and dropdown list D. When A is

    > clicked,
    > > C is required field. When B is clicked, C and D are required fields.

    There
    > > is a dummy entry "please select" in the dropdown list. When B is

    clicked,
    > D
    > > can't be the dummy option.
    > >
    > > I wonder what is the best practice for this case? I was thinking to use
    > > server-side validation for these controls, and created 2 RequiredField
    > > Validators and set them TRUE at designer. Is there anybody who can

    > enlighten
    > > me? Thanks.
    > >
    > >
    > >

    >
    >
     
    Sean, Jul 31, 2003
    #3
    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. Sean

    Help: Requiredfield validator

    Sean, Jul 31, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    393
  2. Bryce Budd

    CheckBoxList RequiredField Validator

    Bryce Budd, Nov 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    6,329
    Bryce Budd
    Nov 22, 2003
  3. =?Utf-8?B?Vmk=?=

    RequiredField Validator question

    =?Utf-8?B?Vmk=?=, Nov 11, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    469
    =?Utf-8?B?Vmk=?=
    Nov 11, 2005
  4. Vinitha

    ASP.NET RequiredField Validator

    Vinitha, Mar 2, 2011, in forum: .NET
    Replies:
    0
    Views:
    910
    Vinitha
    Mar 2, 2011
  5. Sean

    Help: Requiredfield validator

    Sean, Jul 31, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    161
Loading...

Share This Page