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

 date validation

Print topic Send  topic

Author Message
dzulishak

Posts: 12
Posted: 05/09/2013, 11:35 PM

hello i have a question how do i can validate date on my form before insert execute? can some one help me? this my code

tarif2=CCGetFromGet(id_tarif);
$bakiasal=CCGetFromGet(baki_kuantiti);
$tarikhtamat =CCGetFromGet(tkh_tamat);
$jumtolak= $tolak->jum_keluar->GetValue();
$tkhtmmt= $tolak->Label7->GetValue();


//checking bakiasal
if ($bakiasal < $jumtolak)
{

$Container->Errors->addError("Baki Semasa Tidak Mencukupi!");
$tolak->InsertAllowed = false;
$tolak->Errors->addError("Sila Masukan Jumlah Yang Betul!.");

}
//checking date <- i have problem with this code
else if ( $tarikhtamat = $tkhtmmt)
{
$Container->Errors->addError("Tarikh telah Tamat !");
$tolak->InsertAllowed = false;
}
else
{
//penolakan
$jumbaru = $bakiasal - $jumtolak;
$tolak->Label3->SetValue($jumbaru);
//update row table tarif
$db= new clsDBkuantiti;
$sql="UPDATE tarif SET baki_kuantiti =$jumbaru WHERE id_tarif=". $tarif2;
$db->query($sql);
$db->close;
}
View profile  Send private message
MichaelMcDonald

Posts: 639
Posted: 05/10/2013, 12:09 AM

what of date do you want to format?

Date not before?

Date not after?

Date format?
_________________
Central Coast, NSW, Australia.

View profile  Send private message
dzulishak

Posts: 12
Posted: 05/10/2013, 1:01 AM

mr micheal i wanna to validate the date before i execute insert button
View profile  Send private message
MichaelMcDonald

Posts: 639
Posted: 05/10/2013, 2:42 AM

I meant to say what part of date would you like to validate?

Some examples:

Must the date be between 2 dates?

Can the date be earlier than today? or no later than a future date?

Would you like to retrieve the date and set it as a variable?
_________________
Central Coast, NSW, Australia.

View profile  Send private message
dzulishak

Posts: 12
Posted: 05/10/2013, 3:04 AM

owh i mean i want to validate

$tkhtmmt= $tolak->Label7->GetValue();
( $tarikhtamat = $tkhtmmt)
View profile  Send private message
MichaelMcDonald

Posts: 639
Posted: 05/10/2013, 3:27 AM

Not entirely sure what you are asking, does this help ?

if ($tkhtmmt[0] == $tarikhtamat[0])
_________________
Central Coast, NSW, Australia.

View profile  Send private message
MichaelMcDonald

Posts: 639
Posted: 05/10/2013, 3:34 AM

Have a look at this post:

http://forums.yessoftware.com/posts.php?post_id=97052
_________________
Central Coast, NSW, Australia.

View profile  Send private message
dzulishak

Posts: 12
Posted: 05/13/2013, 3:05 AM

hello micheal i'm sorry i dont know how to expalin it because i'm week in english...sorry to make ur day bad .. O:)
actually i want to validate current date before i proceed to insert data example like this :
date 1(insert erlier at form)
date 2 (current date)
if i want to insert data then system would check date 1 and validate the date if date 1 > date 2 then error will display.

thanks micheal
View profile  Send private message
dzulishak

Posts: 12
Posted: 05/13/2013, 5:33 AM

what mean by $date2 ? can you explain it?
thanks O:)
View profile  Send private message
MichaelMcDonald

Posts: 639
Posted: 05/13/2013, 6:59 AM

$date2 = (current date) date 2


_________________
Central Coast, NSW, Australia.

View profile  Send private message
MichaelMcDonald

Posts: 639
Posted: 05/13/2013, 7:26 AM


Try this:

$date2= date('d.m.Y', time());
$date2 = strtotime($date2);

if ($date1[0] > $date2){
$container->Errors->addError("your error message");
}

_________________
Central Coast, NSW, Australia.

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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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