Controlling Date Entry Using Page Extensions

The following article outlines how to use Page Extensions to control what dates can be used when populating a date field on a AdminPortal page.

Restricting the Date to Today or Earlier on the Add Payments and Add Credits pages

  1. Click on Setup

  2. Click Page Extensions

  3. Click the Add button

  4. Enter the following information:
    Name - as listed below
    Page - as listed below
    Script - (see below)

    --paste in code from below as needed

  5. Click Save

Name: Force Date on Add Credit
Page: statementdetailscredittransactions/add

function BillCreditDateCheck() { var de = document.getElementById("Date"); var d = de.value.split("/"); var now = new Date(); if (d[2] > now.getFullYear()) { return false; } if (d[2] == now.getFullYear()) { if (d[1] > (now.getMonth() + 1)) { return false; } if (d[1] == (now.getMonth() + 1)) { if (d[0] > now.getDate()) { return false; } } } } function BillCreditDateCheckOnClick(e) { if (BillCreditDateCheck() == false) { setTimeout("alert('The Date must be less than or equal to today.');", 50); return false; } return this.oldOnClick(e); } var theCrumb = document.getElementById('crumb'); var loggedInUser = theCrumb.getElementsByTagName('a')[0].innerHTML; if (loggedInUser != "rrichardson" && loggedInUser != "obechu" && loggedInUser != "nboirard" && loggedInUser != "bwaasdorp" && loggedInUser != "yjadhav") { document.getElementById("Date").readOnly = true; document.getElementById("Datectlpopup").style.display = 'none'; } else { var sb = document.getElementById("SaveButton"); if (sb != null) { sb.oldOnClick = sb.onclick; sb.onclick = BillCreditDateCheckOnClick; } var snb = document.getElementById("SaveNewButton"); if (snb != null) { snb.oldOnClick = snb.onclick; snb.onclick = BillCreditDateCheckOnClick; } }


Name: Force Date on Add Payment
Page: payment/addpayment

function BillPaymentDateCheck() { var de = document.getElementById("Date"); var d = de.value.split("/"); var now = new Date(); if (d[2] > now.getFullYear()) { return false; } if (d[2] == now.getFullYear()) { if (d[1] > (now.getMonth() + 1)) { return false; } if (d[1] == (now.getMonth() + 1)) { if (d[0] > now.getDate()) { return false; } } } } function BillPaymentDateCheckOnClick(e) { if (BillPaymentDateCheck() == false) { setTimeout("alert('The Date must be less than or equal to today.');", 50); return false; } return this.oldOnClick(e); } var theCrumb = document.getElementById('crumb'); var loggedInUser = theCrumb.getElementsByTagName('a')[0].innerHTML; if (loggedInUser != "rrichardson" && loggedInUser != "obechu" && loggedInUser != "nboirard" && loggedInUser != "bwaasdorp" && loggedInUser != "yjadhav") { document.getElementById("Date").readOnly = true; document.getElementById("Datectlpopup").style.display = 'none'; } else { var sb = document.getElementById("SaveButton"); if (sb != null) { sb.oldOnClick = sb.onclick; sb.onclick = BillPaymentDateCheckOnClick; } var snb = document.getElementById("SaveNewButton"); if (snb != null) { snb.oldOnClick = snb.onclick; snb.onclick = BillPaymentDateCheckOnClick; } }