473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 9791
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Stephen | last post by:
I have some code which I call from a custom validator however I seem to have got the logic wrong and im having trouble figuring out how to write my code to get things to work the way I require....
2
by: Martin | last post by:
Dear Group It says in MSDN that a field can be associated with more than one validators but can one validator be associated with more than one field? Or do I need a validator for each field? How...
6
by: Paul | last post by:
I am trying to setup a field validator and tried using the control to validate set to a dropdown list box but did not seem to work. Is there anyway to set this up or do you need to use client side...
2
by: z. f. | last post by:
Hi, i have a field with required field validator. on the client side it's working. when i submit without the required field the page gets back because of not valid, but the message from the...
6
by: hansiman | last post by:
I'm having trouble getting the required field validator to work. I can still save the row in the datagrid... I can't see what I'm doing wrong. <asp:TemplateColumn SortExpression="c.Password"...
2
by: pmud | last post by:
Hi, I have an ASP.Net web page . The page was working fine until I added a required field field validator. My page has a link button which takes the user to another page, a submit button which...
1
by: SteFetS | last post by:
Here is my bug On my Webform I have 1 Panel with a textbox in it 1 Required field (outside the panel) for the textbox 1 Button (outside the panel) The panel is set to VISIBLE=FALSE
4
by: WebBuilder451 | last post by:
I have a check box for a confirmation that a new member has read the terms and conditions. This is an asp control, but can't seem to get a validator control to reconize it. What is the best way to...
37
by: viki1967 | last post by:
Hi all. I have this simple form. I need if checkbox C_1 is selected: 1) field name="n_1" is required and accept only numbers; 2) field name="n_2" is required and accept only numbers; I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.