Help: Requiredfield validator

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sean

    #1

    Help: Requiredfield validator

    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

    #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.formn ame.dropdownlis tname.selectedI ndex == 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" <ssmith@yahoo.c om> wrote in message
    news:OF3o%23k2V DHA.2168@TK2MSF TNGP09.phx.gbl. ..[color=blue]
    > Hi,
    >
    > I have 2 buttons A and B, textbox C and dropdown list D. When A is[/color]
    clicked,[color=blue]
    > 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,[/color]
    D[color=blue]
    > 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[/color]
    enlighten[color=blue]
    > me? Thanks.
    >
    >
    >[/color]


    Comment

    • Sean

      #3
      Re: Requiredfield validator

      I got the idea. Thank you.

      "Elliot Rodriguez" <elliotmrodrigu ez@hotspammyspa mmail.com> wrote in message
      news:#uHaOb3VDH A.2248@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Sean:
      >
      > I would use a CustomValidator for this. Using JavaScript its really easy[/color]
      to[color=blue]
      > detect if the first item in the dropdown box is selected.
      >
      > Something like:
      >
      > function isFirstPicked()
      > {
      > if (document.formn ame.dropdownlis tname.selectedI ndex == 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" <ssmith@yahoo.c om> wrote in message
      > news:OF3o%23k2V DHA.2168@TK2MSF TNGP09.phx.gbl. ..[color=green]
      > > Hi,
      > >
      > > I have 2 buttons A and B, textbox C and dropdown list D. When A is[/color]
      > clicked,[color=green]
      > > C is required field. When B is clicked, C and D are required fields.[/color][/color]
      There[color=blue][color=green]
      > > is a dummy entry "please select" in the dropdown list. When B is[/color][/color]
      clicked,[color=blue]
      > D[color=green]
      > > 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[/color]
      > enlighten[color=green]
      > > me? Thanks.
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...