COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: pooja on 30 Dec 2009 06:59:51 PM

Title: date validation
Post by: pooja on 30 Dec 2009 06:59:51 PM
java script for date validation in prompt page From date and To date prompt.??

thankx in advance

Title: Re: date validation
Post by: pooja on 03 Jan 2010 12:53:42 PM
 >:(
Title: Re: date validation
Post by: MFGF on 04 Jan 2010 08:14:20 AM
Go to the top level on the forum, use the search field in the top right corner, and enter javascript date.

Isn't that much easier than posting angry faces because nobody has as yet replied?

MF.
Title: Re: date validation
Post by: Sreeni P on 04 Jan 2010 09:07:16 AM
Check this Java script

<script>
var cntlName;
function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function customCheckPage(){
var par1;
var par2;
for( var i=0; i<preProcessControlArray.length; i++){
  cntlName = eval(preProcessControlArray);
  if ( cntlName.m_oSubmit.name.toLowerCase() == '' ){
    eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
    par1 = cntlName.m_oForm.value;
  }   
  if ( cntlName.m_oSubmit.name.toLowerCase() == 'p_p_par_todate' ){
    eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
    par2 = cntlName.m_oForm.value;
  }
}

if (par1<=par2) {
  //alert ('CORRECT');   
  promptButtonFinish();
} else {
  alert('FROM DATE parameter must be smaller than or equal to TO DATE parameter!');
}

for( var i=0; i<pageNavigationObserverArray.length; i++){
  cntlName = eval( pageNavigationObserverArray );
  if(cntlName.m_oParent.onclick.toString().indexOf('promptButtonFinish()')>0 ){
    cntlName.m_oParent.onclick = customCheckPage;
  }
}
for( var i=0; i<preProcessControlArray.length; i++){
  cntlName = eval(preProcessControlArray);
  dt = new Date();
  df = new Date( dt - 30*86400000);
  if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_fromdate' ){
    cntlName.m_oEditBox.value = df.getFullYear()
         + '-' + right('0'+(1+df.getMonth()),2)
         + '-' + right('0'+df.getDate(),2);
    eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
  }
  if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_todate' ){
    cntlName.m_oEditBox.value = dt.getFullYear()
         + '-' + right('0'+(1+dt.getMonth()),2)
         + '-' + right('0'+dt.getDate(),2);
    eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
  }
}
</script>



here the parameters i used :p_par_fromdate(from date)  ,  p_par_todate(to date)


and one more final thing .....................for this script we should thank to "COGNOiSe administrator"
Title: Re: date validation
Post by: s_thammi@yahoo.com on 17 Feb 2010 11:23:06 PM
when I use the above script I am getting error message.

preProcessControlArray is undefined. Does any one know how to fix this?

Thank you
Sridhar
Title: Re: date validation
Post by: s_thammi@yahoo.com on 17 Feb 2010 11:25:35 PM
I am using congos 8.4