Help: Requiredfield validator

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.
 
E

Elliot Rodriguez

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
 
S

Sean

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,
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top