CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 OnValidate Problem ? Bug?

Print topic Send  topic

Author Message
feha


Posts: 712
Posted: 03/29/2004, 9:06 AM

  
//verify_reg1_OnValidate @51-095B1157  
function verify_reg1_OnValidate()  
{  
    $verify_reg1_OnValidate = true;  
//End verify_reg1_OnValidate  
  
//Custom Code @100-C6762D9B  
// -------------------------  
    global $verify_reg1;  
    // Write your own code here.  
	if ($verify_reg1->accept_agreement->GetText()!=1)  
    {  
    $verify_reg1->accept_agreement->Errors->addError("<b>* Accept Agreement & Terms Of Use ?</b>");  
    //$verify_reg1->InsertAllowed = false;  
	}  
  
	if ($verify_reg1->homepage->GetText()=="http://" OR $verify_reg1->homepage->GetText()=="")  
    {  
	$verify_reg1->accept_agreement->Errors->addError("<b>* Homepage URL is required ?</b>");  
	//$verify_reg1->InsertAllowed = false;  
    }  
  
    if ($verify_reg1->homepage->GetText()!="http://" OR $verify_reg1->homepage->GetText()!="")  
	{  
	if(!eregi("^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$", $verify_reg1->homepage->GetText()))  
    {  
    $verify_reg1->accept_agreement->Errors->addError("<b>* Homepage URL format is wrong.</b>");return;  
	//$verify_reg1->InsertAllowed = false;  
	}  
	}	  
  
// -------------------------  
//End Custom Code  
  
//Validate Required Value @107-7D4D73A2  
//Close verify_reg1_OnValidate @51-04907FB8  
    return $verify_reg1_OnValidate;  
}  
//End Close verify_reg1_OnValidate  

I have a problem with OnValidate() function I don't know if this is a CCS BUG?

It shows errors OK but despite errors it inserts values in to DB ?
How to prevent this?
(Normaly it should not insert values)
It is OnValidate (Custom Event)

Anyone else had/has this problems?

regards
femi


_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
peterr


Posts: 5971
Posted: 03/29/2004, 11:59 AM

Hi,
Is "verify_reg1" a form? What type of form? What is ">accept_agreement"?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
feha


Posts: 712
Posted: 03/29/2004, 12:17 PM

$verify_reg1 is a form "Record" ...

http://www.vision.to/DDD_VERIFY/VERIFY_MOD/Register.php

accept_agreement is check box ...
I have tried even this variant
  
function verify_reg1_OnValidate()  
{  
    $verify_reg1_OnValidate = true;  
//End verify_reg1_OnValidate  
  
//Custom Code @100-C6762D9B  
// -------------------------  
    global $verify_reg1;  
    // Write your own code here.  
	if (CCGetParam("accept_agreement","")!=1)  
    {  
    $verify_reg1->accept_agreement->Errors->addError("<b>* Accept Agreement & Terms Of Use ?</b>");  
    }  
  
	if (CCGetParam("homepage","")=="http://" OR CCGetParam("homepage","")=="")  
    {  
	$verify_reg1->accept_agreement->Errors->addError("<b>* Homepage URL is required ?</b>");  
    }  
  
    if (CCGetParam("homepage","")!="http://" OR CCGetParam("homepage","")!="")  
	{  
	if(!eregi("^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$", CCGetParam("homepage","")))  
    {  
    $verify_reg1->accept_agreement->Errors->addError("<b>* Homepage URL format is wrong.</b>");  
	}  
	}  
// -------------------------  
//End Custom Code  
  
//Close verify_reg1_OnValidate @51-04907FB8  
    return $verify_reg1_OnValidate;  
}  
//End Close verify_reg1_OnValidate  
It alerts OK but it inserts a record even its onvalidate (cutom)
Try it online it is a demo anyway but you can test it live ...

How can I prevent Inserting a record if OnValide() is error
this is only if i add onvalidate event not on "regular" validation ...

Thank You


_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
peterr


Posts: 5971
Posted: 03/29/2004, 12:27 PM

Take a look at:
http://docs.codecharge.com/studio/html/ProgrammingTechn...Validation.html
http://docs.codecharge.com/studio/html/ProgrammingTechn...Validation.html

I haven't try this, but the examples show that the error must be added to the form's error collection. Therefore "$verify_reg1->accept_agreement->Errors->addError" probably cannot work because this is a checkbox, not a form.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
feha


Posts: 712
Posted: 03/29/2004, 12:37 PM

The problem is it doesn't work even with :
  
   if (CCGetParam("homepage","")!="http://" OR CCGetParam("homepage","")!="")    
	{    
	if(!eregi("^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$", CCGetParam("homepage","")))    
    {    
    $verify_reg1->accept_agreement->Errors->addError("<b>* Homepage URL format is wrong.</b>");    
	}    
	}    
[7code]  
?  
I'm not sure waht is the problem, what command to use to prevent insert  
on add error ?  
  
                  
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
peterr


Posts: 5971
Posted: 03/29/2004, 12:52 PM

I believe that this should work automatically (if it doesn't then we may have to check into this), but I still see that you are not adding the errors to the form.
In your last example the code "$verify_reg1->accept_agreement->Errors->addError" still doesn't look correct. Our examples show that it should be the form name, not control name. Therefore the code should be "$verify_reg1->Errors->addError".
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
feha


Posts: 712
Posted: 03/29/2004, 1:38 PM

Thank You PeterR

It works great even with checkbox :-)

  
	if ($verify_reg1->accept_agreement->GetValue()!=1)  
    {  
    $verify_reg1->Errors->addError("<b>* Accept Agreement & Terms Of Use ?</b>");  
	}  
  
	if ($verify_reg1->homepage->GetValue()=="http://" OR $verify_reg1->homepage->GetValue()=="")  
    {  
	$verify_reg1->Errors->addError("<b>* Homepage URL is required ?</b>");  
    }  
  
    if ($verify_reg1->homepage->GetValue()!="http://" OR $verify_reg1->homepage->GetValue()!="")  
	{  
	if(!eregi("^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$", $verify_reg1->homepage->GetValue()))  
    {  
    $verify_reg1->Errors->addError("<b>* Homepage URL format is wrong.</b>");  
	}  
	}  

It was my own "BUG" :-) a misstake...
So I corrected as You proposed ...
Quote :
Therefore the code should be "$verify_reg1->Errors->addError".

Thank You
;-)
_________________
Regards
feha

www.vision.to
feedpixel.com
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.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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