Hi,
I have 2 date prompts (From & To both mandatory).
1) I need to set the date prompt values to blank in cognos 10.1
2) From date should always be less than To date
3) From date and To date cannot be greater than current Date (User should not be able to choose future dates)
4) Finish Button should not be enabled until all the Mandatory prompts are selected.
Can anyone tell me the javascript that needs to be used.
I have the following code
<script language="javascript">
document.forms.elements.value='';
</script>
<body oNLoad=init()>
<form name="formWarpRequest">
I tried replacing it with the following in 10.1
<script language="javascript">
getFormWarpRequest().elements.value='';
</script>
I am gettting blank date but the required constraints gets disabled.i.e. the finish button gets enabled even if we have not selected the date values.
Can anyone please help me on this.
Thanks in advance
You might want to remove the default finish button and then add your own Finish button through html item , which on click validates your date prompt values and then forwards to the report page.
eg :-
<input type='button' value='finish' onclick='validateAndFinish()'>
JS to validate and finish :-
Function validateAndFinish () {
// Do ur validation here , n if all goes correct then :
if (canSubmitPrompt()) {
promptAction("next"); // promptButtonFinish();
}
}
As the part for date validations , this might help.
var form = getFormWarpRequest();
var date1 = form._ txtDateFromDt.value;
var date2= form._txtDateToDt.value;
var FromDate = new Date(date1);
var ToDate = new Date(date2);
var curr_date = new Date();
If ( FromDate < ToDate || FromDate > curr_date || ToDate > curr_date ) {
// something wrong so you might wanna show some notification to user n asking them to check the date.
}
else
{
// good to go
}
Hi ,
Thank you so much for the Script.. but could you please let me know what are ('date1','date2', 'Fromdate','Todate') in the script.