CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 [Solved] checkbox validation issue

Print topic Send  topic

Author Message
bogdantc

Posts: 36
Posted: 06/10/2008, 1:14 AM

checkbox has no required property presumably because it has only 2 options: checked and unchecked. yet i would like to put a condition on a checkbox in order not to submit the page if the checbox is not checked.

any ideas?
_________________
Able was I ere I saw Elba
View profile  Send private message
Gena

Posts: 591
Posted: 06/10/2008, 1:26 AM

You need to use Record OnValidate event, like

if ($Component->checkbox->GetValue() <> 1) {
$Component->checkbox->Errors->addError(...);
}
_________________
Gena
View profile  Send private message
bogdantc

Posts: 36
Posted: 06/10/2008, 1:52 AM

is seems it doesn't work because checkbox is not bound to a database column ...

is there anyway to stop submitting from the client if the checkbox is not checked?
_________________
Able was I ere I saw Elba
View profile  Send private message
Gena

Posts: 591
Posted: 06/10/2008, 2:04 AM

Quote bogdantc:
is seems it doesn't work because checkbox is not bound to a database column ...
does't matter

I have a Record for Subscribe/Unsubscribe so it depends from Checkbox and it works:

  
function Header_SubscribeHeader_OnValidate(& $sender)  
{  
    $Header_SubscribeHeader_OnValidate = true;  
    $Component = & $sender;  
    $Container = & CCGetParentContainer($sender);  
    global $Header; //Compatibility  
//End Header_SubscribeHeader_OnValidate  
  
//Custom Code @37-2A29BDB7  
// -------------------------  
  
if ( strlen($Component->email->GetValue()) && preg_match ("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $Component->email->GetText()  ) ){  
    if ($Component->CheckBoxSubscribeMe->GetValue() ) {  
    	SubscribeMe ($Component->email->GetValue(), 1 ); //subscribe  
	} else {  
	SubscribeMe ($Component->email->GetValue(), 0 ); //unsubscribe  
	}  
}  
// -------------------------  
//End Custom Code  
  
return $Header_SubscribeHeader_OnValidate;  

_________________
Gena
View profile  Send private message
bogdantc

Posts: 36
Posted: 06/10/2008, 2:05 AM

i tried to use Validation rule property also but I did not find anything to work yet ..
_________________
Able was I ere I saw Elba
View profile  Send private message
bogdantc

Posts: 36
Posted: 06/10/2008, 2:14 AM

hooray ... thanks to your hint i find out another way to do it :-D i have used indeed the Record validation and I have added the Action Validate minimum value in which i put my checkbox name and 1 as minimum accepted value 8-)
_________________
Able was I ere I saw Elba
View profile  Send private message
Gena

Posts: 591
Posted: 06/10/2008, 2:17 AM

you are smart :-)

btw at the end this will produce a similar code...
_________________
Gena
View profile  Send private message
Gena

Posts: 591
Posted: 06/10/2008, 2:21 AM

btw this code also works for me

  
//Agreement_OnValidate  
if ($Component ->CheckBoxAgree->GetValue() == 0) 	{  
    $Component ->CheckBoxAgree->Errors->addError("You should agree with this agreement!");  
}  

_________________
Gena
View profile  Send private message
bogdantc

Posts: 36
Posted: 06/10/2008, 3:03 AM

i use ASP .NET with C# 2.0 ... writing code manually didn't work but using that action did the trick ... indeed the code generated is absolutely the same ... perhaps it's a hidden mechanism from .NET that prevents the written code to work properly ... anyway thanks again ...
_________________
Able was I ere I saw Elba
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.