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
|
 |
 |
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
|
 |
 |
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 |
 |
 |
cancerian
Posts: 9
|
| Posted: 03/08/2010, 12:20 PM |
|
Worked perfect....Thanks for your help.
|
 |
 |