Вы находитесь на странице: 1из 2

summary:

community content
business rules-the most important one (blogs)
re: information from a date till ... (groups)
can you tell me how can i give validation in the report prompt page so that the
user has an end date that is always greater then the start date?
full article:
disclaimer: contents are not reviewed for correctness and are not endorsed or
recommended by ittoolbox or any vendor. popular q&a contents include summarized
information from ittoolbox cognos-reportnet-l discussion unless otherwise noted.

adapted from response by ratikant on wednesday, august 17, 2005

follow the steps:


1. give ids to both the date prompts (in the code below it's fromdate and todate).

script xmlns:xie5="http://developer.cognos.com/prompting/xie5"
language="javascript" src="../prompting/cpromptbutton.js" type="text/javascript"
//leave this comment here to assure we have an explicit end tag for scriptscript
function chkdate()
{
var fromdate=document.forms[0].elements["_ochoicestartdate"].value;
var j=0;
var fromdatearr=new array(2);
for(i=0;i{

if(fromdate.charat(i)"-")
{

fromdatearr[j]=i;
j++;
}

var fromdateyear=parseint(fromdate.substring(0,fromdatearr[0]));
if(fromdate.charat(5)"0")
{
var fromdatemonth=parseint(fromdate.substring(fromdatearr[0]+2,fromdatearr[1]));
}
else
{
var fromdatemonth=parseint(fromdate.substring(fromdatearr[0]+1,fromdatearr[1]));
}

var fromdateday=parseint(fromdate.substring(fromdatearr[1]+1,fromdate.length),10);
var x=fromdate.substring(5,7);

var todate=document.forms[0].elements["_ochoiceenddate"].value;
var k=0;
var todatearr=new array(2);

for(i=0;i {

if(todate.charat(i)"-")
{
todatearr[k]=i;
k++;
}

}
var todateyear=parseint(todate.substring(0,todatearr[0]));
if(todate.charat(5)'0')
{
var todatemonth=parseint(todate.substring(todatearr[0]+2,todatearr[1]));
}
else
{
var todatemonth=parseint(todate.substring(todatearr[0]+1,todatearr[1]));
}
var todateday=parseint(todate.substring(todatearr[1]+1,todate.length),10);

if(document.forms[0].elements["txtdatestartdate"].value!="" &&
document.forms[0].elements["txtdateenddate"].value!="")
{

if(fromdateyear>todateyear)
{
alert("end date should be greater than start date.");
return false;
}else if(fromdateyeartodateyear)
{
if(fromdatemonth>todatemonth)
{
alert("end date should be greater than start date.");
return false;
}else if(fromdatemonthtodatemonth)
{
if(fromdateday>todateday)
{
alert("end date should be greater than start date.");
return false;
}
}
}

}
}

function submitbtn()
{

if(chkdate()!= false)

promptbuttonfinish();

/script

Вам также может понравиться