all groups > asp.net webcontrols > july 2003 >
You're in the

asp.net webcontrols

group:

Help: Requiredfield validator


Help: Requiredfield validator Sean
7/31/2003 8:40:00 AM
asp.net webcontrols:
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.


Re: Requiredfield validator Sean
7/31/2003 11:07:43 AM
I got the idea. Thank you.

[quoted text, click to view]

Re: Requiredfield validator Elliot Rodriguez
7/31/2003 11:15:29 AM
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***



[quoted text, click to view]

AddThis Social Bookmark Button