468,101 Members | 1,378 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,101 developers. It's quick & easy.

required field validator not working for checkbox.

greetings

i want to use the required field validator control to validate a checkbox.
here is the code implemented.

<asp:RequiredFieldValidator ID="rfv" ControlToValidate="chkDistiAudit"
ErrorMessage="error" runat="server" />

<asp:checkbox id="chkDistiAudit" runat="server" CssClass="objControl_left"
Width="100px" Text="Disti Audit" Checked="True"></asp:checkbox>

and below is the error return

Control 'chkDistiAudit' referenced by the ControlToValidate property of
'rfv' cannot be validated.

can somone please help me out here?.
thanks...
Nov 18 '05 #1
2 9542
I question your desire to use it on a checkbox. A checkbox has two valid
values, checked and unchecked. Each is valid. From a user-interface-design
perspective, perhaps you should use a different type of input.

"Asha" wrote:
greetings

i want to use the required field validator control to validate a checkbox.
here is the code implemented.

<asp:RequiredFieldValidator ID="rfv" ControlToValidate="chkDistiAudit"
ErrorMessage="error" runat="server" />

<asp:checkbox id="chkDistiAudit" runat="server" CssClass="objControl_left"
Width="100px" Text="Disti Audit" Checked="True"></asp:checkbox>

and below is the error return

Control 'chkDistiAudit' referenced by the ControlToValidate property of
'rfv' cannot be validated.

can somone please help me out here?.
thanks...

Nov 18 '05 #2
Simply put, Checkboxes are not supported by the predefined validators. You
can write your own code with a CustomValidator to detect the state of the
checkbox and report an error.

My replacement to Microsoft's validators, Professional Validation and More
(http://www.peterblum.com/vam/home.aspx) includes a CheckStateValidator for
checkboxes and radiobuttons amongst the 22 validators it offers. I wrote
Professional Validation And More after finding numerous limitations in
Microsoft's validators that required custom coding and creative hacks to
resolve. I put together a list of the limitations that I've found here:
http://www.peterblum.com/vam/valmain.aspx.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Asha" <As**@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
greetings

i want to use the required field validator control to validate a checkbox.
here is the code implemented.

<asp:RequiredFieldValidator ID="rfv" ControlToValidate="chkDistiAudit"
ErrorMessage="error" runat="server" />

<asp:checkbox id="chkDistiAudit" runat="server" CssClass="objControl_left"
Width="100px" Text="Disti Audit" Checked="True"></asp:checkbox>

and below is the error return

Control 'chkDistiAudit' referenced by the ControlToValidate property of
'rfv' cannot be validated.

can somone please help me out here?.
thanks...

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Stephen | last post: by
2 posts views Thread by Martin | last post: by
6 posts views Thread by hansiman | last post: by
1 post views Thread by SteFetS | last post: by
4 posts views Thread by WebBuilder451 | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.