Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Help: Requiredfield validator

Reply
Thread Tools

Help: Requiredfield validator

 
 
Sean
Guest
Posts: n/a
 
      07-31-2003
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.



 
Reply With Quote
 
 
 
 
Elliot Rodriguez
Guest
Posts: n/a
 
      07-31-2003
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" <(E-Mail Removed)> wrote in message
news:OF3o%(E-Mail Removed)...
> 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.
>
>
>



 
Reply With Quote
 
 
 
 
Sean
Guest
Posts: n/a
 
      07-31-2003
I got the idea. Thank you.

"Elliot Rodriguez" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:OF3o%(E-Mail Removed)...
> > 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.
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET RequiredField Validator Vinitha ASP .Net 0 03-02-2011 05:20 AM
RequiredField Validator question =?Utf-8?B?Vmk=?= ASP .Net 4 11-11-2005 09:01 PM
CheckBoxList RequiredField Validator Bryce Budd ASP .Net 0 11-22-2003 11:49 PM
CheckBoxList RequiredField Validator Bryce Budd ASP .Net Building Controls 0 11-22-2003 11:49 PM
Help: Requiredfield validator Sean ASP .Net Datagrid Control 2 07-31-2003 04:07 PM



Advertisments