473,387 Members | 1,520 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,387 software developers and data experts.

CustomValidator for checkboxes?

Hi all...

I'm trying to use a custom validator for a group of checkboxes in order to
validate that at least 1 checkbox is checked before submitting the form.

I placed 2 checkbox controls in the form and a CustomValidator. When I saw
CustomValidator properties, the checkboxes aren't listed in ControlToValidate
properties. Only textboxes are listed. Also, I set the ValidationGroup for
the checkboxes to a name such as grpTipoEnvio and that name didn't appear in
that list either.

The JavaScript function is implemented this way:

function ValidaCheck(source, arguments)
{
var arguments.isValid = false;
var len = source.length;
if( len && len > 0 )
for( var i = 0; i < len; i++ )
arguments.isValid |= source[i].checked;
else
arguments.isValid = source.checked;
}
Is it possible to use this control to validate checkboxes? if not, how can I
accomplish this?

Thanks a ot in advance
Jaime
Nov 19 '05 #1
3 1780
Jaime,

I created a CheckBoxListRequiredFieldValidator control. It has both
clientside and server side validation and operates just like a regular
required field validator except that you can specify how many checkboxes
need to be checked.

You may download the control for free from here:
http://www.aboutfortunate.com/defaul...xlistvalidator

The control come as a Visual Studio 2003 project and is completely free to
use as you wish with all source code.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jaime Stuardo" <Ja**********@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
Hi all...

I'm trying to use a custom validator for a group of checkboxes in order to
validate that at least 1 checkbox is checked before submitting the form.

I placed 2 checkbox controls in the form and a CustomValidator. When I saw
CustomValidator properties, the checkboxes aren't listed in
ControlToValidate
properties. Only textboxes are listed. Also, I set the ValidationGroup for
the checkboxes to a name such as grpTipoEnvio and that name didn't appear
in
that list either.

The JavaScript function is implemented this way:

function ValidaCheck(source, arguments)
{
var arguments.isValid = false;
var len = source.length;
if( len && len > 0 )
for( var i = 0; i < len; i++ )
arguments.isValid |= source[i].checked;
else
arguments.isValid = source.checked;
}
Is it possible to use this control to validate checkboxes? if not, how can
I
accomplish this?

Thanks a ot in advance
Jaime

Nov 19 '05 #2
Thanks Justin !

I have downloaded your control and after a few changes and corrections I
could use it.

- Changes

I use Visual Studio 2005 so I changed Me.Page.IsClientScriptBlockRegistered
(obsolete in 2005) to Page.ClientScript.IsClientScriptBlockRegistered

- Corrections

1.- in the first IF block of ClientScript method the word "verification" is
misspelled (it is written as checkboxlist_verifictation)

2.- in the first IF block, a call to RegisterClientScriptBlock was missing.

After those changes, validation works perfect!

Thanks again
Jaime

"S. Justin Gengo" wrote:
Jaime,

I created a CheckBoxListRequiredFieldValidator control. It has both
clientside and server side validation and operates just like a regular
required field validator except that you can specify how many checkboxes
need to be checked.

You may download the control for free from here:
http://www.aboutfortunate.com/defaul...xlistvalidator

The control come as a Visual Studio 2003 project and is completely free to
use as you wish with all source code.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jaime Stuardo" <Ja**********@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
Hi all...

I'm trying to use a custom validator for a group of checkboxes in order to
validate that at least 1 checkbox is checked before submitting the form.

I placed 2 checkbox controls in the form and a CustomValidator. When I saw
CustomValidator properties, the checkboxes aren't listed in
ControlToValidate
properties. Only textboxes are listed. Also, I set the ValidationGroup for
the checkboxes to a name such as grpTipoEnvio and that name didn't appear
in
that list either.

The JavaScript function is implemented this way:

function ValidaCheck(source, arguments)
{
var arguments.isValid = false;
var len = source.length;
if( len && len > 0 )
for( var i = 0; i < len; i++ )
arguments.isValid |= source[i].checked;
else
arguments.isValid = source.checked;
}
Is it possible to use this control to validate checkboxes? if not, how can
I
accomplish this?

Thanks a ot in advance
Jaime


Nov 19 '05 #3
Jaime,

Thanks for letting me know about the typo and missing method call. I'm
updating the code and will redeploy with the fixes. I'm starting to use
Visual Studio 2005 myself, but haven't converted my code library over yet.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jaime Stuardo" <Ja**********@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
Thanks Justin !

I have downloaded your control and after a few changes and corrections I
could use it.

- Changes

I use Visual Studio 2005 so I changed
Me.Page.IsClientScriptBlockRegistered
(obsolete in 2005) to Page.ClientScript.IsClientScriptBlockRegistered

- Corrections

1.- in the first IF block of ClientScript method the word "verification"
is
misspelled (it is written as checkboxlist_verifictation)

2.- in the first IF block, a call to RegisterClientScriptBlock was
missing.

After those changes, validation works perfect!

Thanks again
Jaime

"S. Justin Gengo" wrote:
Jaime,

I created a CheckBoxListRequiredFieldValidator control. It has both
clientside and server side validation and operates just like a regular
required field validator except that you can specify how many checkboxes
need to be checked.

You may download the control for free from here:
http://www.aboutfortunate.com/defaul...xlistvalidator

The control come as a Visual Studio 2003 project and is completely free
to
use as you wish with all source code.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jaime Stuardo" <Ja**********@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
> Hi all...
>
> I'm trying to use a custom validator for a group of checkboxes in order
> to
> validate that at least 1 checkbox is checked before submitting the
> form.
>
> I placed 2 checkbox controls in the form and a CustomValidator. When I
> saw
> CustomValidator properties, the checkboxes aren't listed in
> ControlToValidate
> properties. Only textboxes are listed. Also, I set the ValidationGroup
> for
> the checkboxes to a name such as grpTipoEnvio and that name didn't
> appear
> in
> that list either.
>
> The JavaScript function is implemented this way:
>
> function ValidaCheck(source, arguments)
> {
> var arguments.isValid = false;
> var len = source.length;
> if( len && len > 0 )
> for( var i = 0; i < len; i++ )
> arguments.isValid |= source[i].checked;
> else
> arguments.isValid = source.checked;
> }
>
>
> Is it possible to use this control to validate checkboxes? if not, how
> can
> I
> accomplish this?
>
> Thanks a ot in advance
> Jaime


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: jcpmeticulus | last post by:
Hi I've spent the last day or so debugging a problem with a CustomValidator and am now totally stumped! Basically I use a number of CustomValidator's on my page, but have cut this down now to...
2
by: Stephen Miller | last post by:
Can the CustomValidator be used to simply report unexpected errors, without requiring Client/Server validation? To explain, say you had a simple text box and button that did a Full-text Search of a...
3
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server....
1
by: SMG | last post by:
Hi All. My forms has two textboxes, 1 username, 2 password. Both has requiredfield validator it works fine when there is no input in these textboxes. And the errorMsg is shown in...
0
by: ghafranabbas | last post by:
This is how you use the customvalidator control in any INamingContainer interface control (Datagrid, DataList, DataRepeater, etc). 1. In the ItemTemplate, place your customvalidator 2. Set the...
1
by: Beffmans | last post by:
Hi I have defined an customvalidator on my TextBox: function clientvalidate(source, arguments){ { // even number? if (arguments.Value%2 == 0) arguments.IsValid = true; else
1
by: avp | last post by:
Hi, We have an ASP.NET 2.0 (C#) application that has a web form with a CheckBoxList control and a CustomValidator control. The CustomValidator control is used to validate that at least one...
1
by: David | last post by:
I need help with CustomValidator in 1.1. I added the CustomValidator control and code as per the doc., (See below) However, the code is never executed. Is there an extra switch or setting to...
2
by: Jeff | last post by:
hey net 3.5 I have problem with a customvalidator. I enter values into the TextBox named "txt" and clicks on the save button (ibSave) then the TestValidate method get triggered. TestValidate...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.