COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: sg24 on 12 Apr 2011 08:02:53 AM

Title: Date Prompt
Post by: sg24 on 12 Apr 2011 08:02:53 AM
Hi,

I have a date prompt ( called end date) in my prompt page, and i need to validate the date when the user select end date <=getdate() , it has to alert a message saying "select a current or future date ' .
Please suggest how this can be achieved? I am using cognos 8.0 version.

Thanks in advance.

Thanks,
sg24
Title: Re: Date Prompt
Post by: kattaviz on 12 Apr 2011 01:25:31 PM
Hi,

You can do this using Javascript. Please see the below script.

<script type="text/javascript">
function CheckDate()
{
if (document.forms["formWarpRequest"].elements["XXX"].value
>document.forms["formWarpRequest"].elements["ZZZ"].value)
{
alert("Start date must be less than end date")
}
else
{
(promptButtonFinish())
}
}
</script>

Where XXX and ZZZ are the names of your date prompt controls.

HTH
Title: Re: Date Prompt
Post by: sg24 on 13 Apr 2011 03:30:39 AM
Hi ,

Thank you for the response and code. But i have only one date propmt and i need to validate with getdate(). So i modified the code to

<html>
<head>
<script>
function DummyCheckSelection()
{
var dt= new Date();
var my_date= dt.getDate();
End_Date = document.formWarpRequest._oLstChoicesEndDate.value ;

if(End_Date<my_date)
{
alert('select );
}
return;

}
</script>
</head>
<body onclick = "DummyCheckSelection()">
</body>

here EndDate refers to date prompt name. This code doesn't work. Let me know if there is wrong anywhere.

Also when i display a message , how do i validate at the report level? Meaning the user should not be able to run the report if he selects the date which is less than today.

Any suggestions please let me knw.

Thanks,
Sg