Sunday 2 November 2014

Report Studio : JavaScript for Date Validation

I keep receiving a lot of requests for Date Validation Javascript, thought I would share the same. Though this information is available on millions of sites, thought this could be of some use to all those who use this blog often.

Step 1: Drag 2 Date Prompts into the prompt page

Step 2: Name the Date Prompts as FromDate and ToDate

Step 3: Drag an HTML Item below the prompts and include the below script:


<script type="text/javascript">
function validateDate()
{
var fW = (typeof getFormWarpRequest == "function" ?getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined)
{ fW = ( formWarpRequest_THIS_ ?formWarpRequest_THIS_ : formWarpRequest_NS_ );
}

var FromDate = fW.txtDateFromDate.value;
var ToDate = fW.txtDateToDate.value;

if(FromDate > ToDate)
{alert('From Date is greater than To Date');}
else
{promptAction('finish');}
}
</script>



Step 4: Drag another HTML Item to create the prompt button. The onclick event of the button will trigger the date validation function.


<input type=button onclick='validateDate()' value='Finish'>


Step 5: Drag a Prompt Button - Finish to enable the submission of the prompt page and hide the button by seting the height and width to 0px.

No comments:

Post a Comment