Help: Requiredfield validator

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

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:

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
 
I got the idea. Thank you.

Elliot Rodriguez said:
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***



clicked,
 
Back
Top