I need to validate 2 date that never should be same.If same it will return false.Code is in PHP.It is always giving o/p as false.
function BeforeAdd($values, $me
U can use fucntion strtotime and compare it
$d1 = "1/2/2015";
$d2= "1/2/2016";
if ( strtotime($d1) == strtotime($d2) )
echo "same";
else
echo "different";
copy this code and test it i resolve your problem this is my last edit
<?php
$d1 = "1/2/2015";
$d2= "1/2/2015";
if ( strtotime($d1) != strtotime($d2) ) {
return true;
}
else
{
echo '<script type="text/javascript">';
echo 'alert("Application date and leave date should be different.")';
echo '</script>';
return false;
}
?>
function BeforeAdd($values, $message='', $inline='', $pageObject='') {
$d1 =$values['DATE']; //date 1 in dd/mm/yyyy format
$d2 =$values['DATE_OF_LEAVE']; //date 2 in dd/mm/yyyy format
if($d1 <> $d2) {
return true;
}
echo '<script type="text/javascript">';
echo 'alert("Application date and leave date should be different.")';
echo '</script>';
return false;
}
You need to change $values['DATE OF LEAVE']
to $values['DATE_OF_LEAVE']
.
Also in the example you have some fields you don't use - I made them optional and changed the javascript code a little.
Any one can suggest me a code to return false id date is today else true in the format
function BeforeAdd($values, $message, $inline, $pageObject)
{
$d1 = $values['DATE']; //date 1 in dd/mm/yyyy format
$d2 = now();
if($d1>$d2)
{
return true;
}
echo '<script language="javascript">';
echo 'alert(Application date and leave date should be different.)';
echo '</script>';
return false;
}