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 -> PHP

 Validation rule for date

Print topic Send  topic

Author Message
cancerian

Posts: 9
Posted: 03/07/2010, 11:04 AM

Does anyone know how I can use the validation rule to check the entered date ? Basically trying to validate entered date to be equal to or greater than current date .

Any help is appreciated. Thanks
View profile  Send private message
datadoit
Posted: 03/07/2010, 12:46 PM

One way would be to add a hidden field in your form and define it the
same was as your other date entry field, and set it's default value to
CurrentDate. Then for the validation rule for your date entry field
compare as:

$Component->GetValue() >= $Container->Hidden_date->GetValue()

Untested.
cancerian

Posts: 9
Posted: 03/07/2010, 2:48 PM

Thanks for the idea...I tried different combinations of what you sent but I keep getting the error :

Fatal error: Call to a member function GetValue() on a non-object

I followed the steps you sent and used following in validation rule :

$this->GetValue() >= $Container->Hidden_date->GetValue()

I even tried :

$formname->entered_date->GetValue() >= $Container->Hidden_date->GetValue()

Any ideas whatI may be missing? Thanks
View profile  Send private message
laneoc

Posts: 154
Posted: 03/07/2010, 8:33 PM

Here is a snippet from which you can develop what you need:

  
if (strlen($Container->edate->GetText()))   
{    if (date('Y-m-d',strtotime($Container->bdate->GetText())) > date('Y-m-d',strtotime ($Container->edate->GetText())))  
      {    $Container->edate->Errors->addError("End date must be on or after start date.");}  
}  

It reads like this ---
If the End Date is not null...
Compare the dates -- after converting them from text to a date in Y-m-D format...
If the begin date is after the end date, add an error.

I have this placed in the On Validate event of the bdate field.

Hope this helps.

Lane O.
_________________
Lane
View profile  Send private message
cancerian

Posts: 9
Posted: 03/08/2010, 12:20 PM

Worked perfect....Thanks for your help.
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.