Hi,
I am using the following javascript (taken from one of the posts here) to compare from and two dates.
Javascript is places to the right of finish button.
Two parameters are par_fromdate and par_todate.
I am using two edit box date prompts.
Its not prompting error for from date > to date.
Can you please help me to figureout the error.
Thanks
<script type="text/javascript">
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() == 'par_fromdate' )
{
eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
par1 = cntlName.m_oForm.value;
}
if (cntlName.m_oSubmit.name.toLowerCase() == '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() == '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() == '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>