CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 Admin event in CCS to validate data before...

Print topic Send  topic

Author Message
Marc
Posted: 07/22/2002, 7:44 AM

I'm comng back with my problem I want like in Event tutorial validate the form
before it would be on the net can someone help me on how to do it, Thanks in CCS I Work with PHP
George L.
Posted: 07/22/2002, 10:13 AM

Here is an example of a custom validation event.

The basic way to create custom validations is to use the format:

if (condition){
$formname->Errors->addError();
}

This will send an error to your form stating the custom error you put in if condition is true.

Below is an example of validating a password field by forcing the user to input the password twice, then validating the two inputs.

NOTE: $formname->fieldname->GetValue() is a way to get the POST value inputted on the field.

As you can see, I have a form called "ChangePass" and two fields; one called USER_PASS and the other called USER_PASS2.



//Make sure entered password fields match each other.
if ( $ChangePass->USER_PASS->GetValue() != $ChangePass->USER_PASS2->GetValue() ){
$ChangePass->Errors->addError("\nInvalid Input.<br>Password and Confirm Password fields don't match.");

//Reset fields to null
$ChangePass->USER_PASS->SetValue("");
$ChangePass->USER_PASS2->SetValue("");


}

This should work for many different fields and many different validations. Just use if/elseif statements of maybe a switch.
Just be sure to put this code in your OnValidate Event.

Hope that helps a bit.
George L.
Posted: 07/22/2002, 10:19 AM

Don't forget to globalize your formname before the code is executed.

Like this: global $formname
Marc
Posted: 07/23/2002, 1:38 AM

Georges,
I did step by step your explanations but I got the following error message
Call to a member function on a non object?
Why? Thanks
Nicole
Posted: 07/25/2002, 5:07 AM

Marc,
what event have you built and what line you got the error on?

   


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.