Click to See Complete Forum and Search --> : RequiredFieldValidator + CheckBox ?
Simon
03-13-2002, 07:15 PM
Is it possible to use a RequiredFieldValidator to validate a CheckBox there-by
making the checking of it mandatory for submission of the form?
I've tried adding a RequiredFieldValidator for the checkbox and all i get
is an error message: Control 'deleteDisclaimerCheckbox' referenced by the
ControlToValidate property of 'deleteDisclaimerValidator' cannot be validated.
Here's the code snippet...
<asp:CheckBox ID="deleteDisclaimerCheckbox" runat="server" />
<asp:RequiredFieldValidator ID="deleteDisclaimerValidator" ControlToValidate="deleteDisclaimerCheckbox"
Runat="server" />
Constance J. Petersen
03-14-2002, 02:44 PM
--
Constance Petersen, DevX newsgroup section leader
SoftMedia Artisans, Inc.
http://www.smartisans.com
For useful, usable software and Web sites
Featured Web design: http://www.keweenawnow.com/
--
Please reply in the newsgroup so everyone can benefit
"Simon" <simon.stafford@peakhour.com.au> wrote in message
news:3c8feb96$1@10.1.10.29...
>
> Is it possible to use a RequiredFieldValidator to validate a CheckBox there-by
> making the checking of it mandatory for submission of the form?
>
> I've tried adding a RequiredFieldValidator for the checkbox and all i get
> is an error message: Control 'deleteDisclaimerCheckbox' referenced by the
> ControlToValidate property of 'deleteDisclaimerValidator' cannot be validated.
>
> Here's the code snippet...
>
> <asp:CheckBox ID="deleteDisclaimerCheckbox" runat="server" />
> <asp:RequiredFieldValidator ID="deleteDisclaimerValidator"
ControlToValidate="deleteDisclaimerCheckbox"
> Runat="server" />
Constance J. Petersen
03-14-2002, 02:59 PM
Hi Simon,
"Simon" <simon.stafford@peakhour.com.au> wrote in message
news:3c8feb96$1@10.1.10.29...
> Is it possible to use a RequiredFieldValidator to validate a CheckBox there-by
> making the checking of it mandatory for submission of the form?
The CheckBox control is not listed in the documentation as a control that can be
validated. Per the docs, the controls that can be validated are: TextBox,
ListBox, DropDownList, RadioButtonList,
System.Web.UI.HtmlControls.HtmlInputText,
System.Web.UI.HtmlControls.HtmlInputFile, System.Web.UI.HtmlControls.HtmlSelect
and System.Web.UI.HtmlControls.HtmlTextArea.
If you want to use the Validator controls, you could put "Yes" and "No" values
into a ListBox or a RadioButtonList. Then use the RequiredFieldValidator to make
sure one or the other value was entered and a RegularExpressionValidator to make
sure "Yes" was entered.
--
Constance Petersen, DevX newsgroup section leader
SoftMedia Artisans, Inc.
http://www.smartisans.com
For useful, usable software and Web sites
Featured Web design: http://www.keweenawnow.com/
--
Please reply in the newsgroup so everyone can benefit
Simon
03-14-2002, 05:20 PM
Ahh... well that explains things, i scanned the docs in visual studio but
couldn't find any reference as to what controls can have a RequiredFieldValidator
applied to them. Thanks for your list.
Am going to try using a CustomValidator, that way i can still use the checkbox.
Cheers,
Simon.
"Constance J. Petersen" <constance@smartisans.com> wrote:
>Hi Simon,
>
>"Simon" <simon.stafford@peakhour.com.au> wrote in message
>news:3c8feb96$1@10.1.10.29...
>> Is it possible to use a RequiredFieldValidator to validate a CheckBox
there-by
>> making the checking of it mandatory for submission of the form?
>
>The CheckBox control is not listed in the documentation as a control that
can be
>validated. Per the docs, the controls that can be validated are: TextBox,
>ListBox, DropDownList, RadioButtonList,
>System.Web.UI.HtmlControls.HtmlInputText,
>System.Web.UI.HtmlControls.HtmlInputFile, System.Web.UI.HtmlControls.HtmlSelect
>and System.Web.UI.HtmlControls.HtmlTextArea.
>
>If you want to use the Validator controls, you could put "Yes" and "No"
values
>into a ListBox or a RadioButtonList. Then use the RequiredFieldValidator
to make
>sure one or the other value was entered and a RegularExpressionValidator
to make
>sure "Yes" was entered.
>--
>Constance Petersen, DevX newsgroup section leader
>SoftMedia Artisans, Inc.
>http://www.smartisans.com
>For useful, usable software and Web sites
>Featured Web design: http://www.keweenawnow.com/
>--
>Please reply in the newsgroup so everyone can benefit
>
>
>
>
"Simon" <simon.stafford@peakhour.com.au> wrote:
>
>Is it possible to use a RequiredFieldValidator to validate a CheckBox there-by
>making the checking of it mandatory for submission of the form?
>
>I've tried adding a RequiredFieldValidator for the checkbox and all i get
>is an error message: Control 'deleteDisclaimerCheckbox' referenced by the
>ControlToValidate property of 'deleteDisclaimerValidator' cannot be validated.
>
>Here's the code snippet...
>
><asp:CheckBox ID="deleteDisclaimerCheckbox" runat="server" />
><asp:RequiredFieldValidator ID="deleteDisclaimerValidator" ControlToValidate="deleteDisclaimerCheckbox"
>Runat="server" />
devx.com
Copyright Internet.com Inc. All Rights Reserved