Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Client-side custom checkbox validator


Message #1 by "Sean Marchiafava" <smarch@c...> on Tue, 20 Aug 2002 17:01:46
Hovik,

Thanks for leading me in the right direction.  My problem all along was 
that I needed to be able to pass a value to my javascript validation 
routine.  I couldn't hardcode the object to check because I am building 
my forms entirely programatically from a database and it changes 
depending on the form I am building.  Here is what I did.

I assigned the validators id as a delimited string of object ids. I then 
split the id's and looped through to check

example - customvalidator.id = "val" & "1,2,3,4"

function validateckboxes(source, arguments)
 {
  //Validates a group of checkboxes has at least one checkbox checked 
 var validator_array = source.id.split("~");
 var ctrl_array = validator_array[1].split(",");
 var index=0;
 var checkcount=0;
 while (index < ctrl_array.length)
 { 
  
  var elemsourc
    var controlid = source.id.substr(3,source.id.length)
    for(i=0;i<document.forms[0].elements.length;i++)
     {
		elemsourc=document.forms[0].elements[i]
		if (elemsourc.name.indexOf(ctrl_array[index])!=-1)
		{
			if (elemsourc.checked == true)
			{
			checkcount+=1
			}
		}
	 }
	 index+=1
 }
if (checkcount >= 1)
    {
	   arguments.isvalid = true;
	  return;
	}
	 arguments.IsValid = false;

}



> there is no diffrent b/w controld u just use 
ClientValidationFunction="?????" property
for all web control that they can support it!

Thats all for now,
Hovik.

----- Original Message -----
From: "Sean Marchiafava" <smarch@c...>
To: "ASPX_Professional" <aspx_professional@p...>
Sent: Tuesday, August 20, 2002 5:20 PM
Subject: [aspx_professional] Re: Client-side custom checkbox validator


Do you have any examples for checkboxes?  I have done it for textboxes as
your sample below but this is the first attempt for a checkbox and I'm
not having any luck.  I understand the technique to implement client-side
validation but have trouble with this specific control type.

Thanks,
Sean Marchiafava




  Return to Index