Hi
Below is the code for validate date in php (server side validations).
/************************************************
function to check if date entered by date control
is valid date or not
************************************************/
function validdate($tmpdate,$id,$action,$backpg)
{
list($year, $month, $day)=split('[/,.-]', $tmpdate);
$date=$year."-".$month."-".$day;
if(strlen($day)>2)
{
$msg= "Invalid date formats: $tmpdate";
header("location:$backpg?msg=$msg&id=$id&action=$action");
exit;
}
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $tmpdate, $regs))
{
$a= strlen("$regs[3]");
if($a>2)
{
$msg= "Invalid date formats: $tmpdate";
header("location:$backpg?msg=$msg&id=$id&action=$action");
exit;
}
elseif($regs[2]>12)
{
$msg= "Invalid date format: $tmpdate";
header("location:$backpg?msg=$msg&id=$id&action=$action");
exit;
}
elseif($regs[3]>31)
{
$msg= "Invalid date format: $tmpdate";
header("location:$backpg?msg=$msg&id=$id&action=$action");
exit;
}
}
else
{
$msg= "Invalid date format: $tmpdate";
header("location:$backpg?msg=$msg&id=$id&action=$action");
exit;
}//closing else
}
Monday, May 19, 2008
validate date by php script
Subscribe to:
Post Comments (Atom)
1 comment:
Looking for top-notch Laravel development services? Look no further than Connect Infosoft Technologies. We are a leading software development company with a strong expertise in Laravel framework. Our team of experienced developers excels in delivering high-quality and scalable web applications using Laravel. Looking for Laravel Dev Team in India
Post a Comment