I am building the tabular form in oracle apex where I need to validate the start date and end date.
I have date picker field in tabular form for both start date and end date and the start date should not accept the date less 45 days from system date(today's date) and it should not be greater than system date.
I am getting the error even though I have given start date as today's date. I need the alert, when start_date is less than (today's date - 45 days)
I am using ORACLE APEX 5.0 version
On the page I have defined this function in the "Function and Global Variable Declaration" section:
function f_validate_sd(pThis) {
var row_id = pThis.id.substr(4);
var start_date = $('#f10_'+row_id).val();
//var end_date = $('#f11_'+row_id).val();
var currentDate = new Date();
var dy = currentDate.getDate();
var month = currentDate.getMonth() + 1;
var year = currentDate.getFullYear();
var sd = ( dy + "-" + month + "-" + year);
var subdate = new Date(sd);
var numberOfDaysToAdd = 45;
subdate.setDate(subdate.getDate() - numberOfDaysToAdd );
var dd = subdate.getDate();
var mm = subdate.getMonth() + 1;
var yy = subdate.getFullYear();
var sub = ( dd + "-" + mm + "-" + yy );
alert(start_date);
alert(sub);
alert(start_date - sub );
alert(sd);
if(start_date < sub ) {
alert("START DATE should be within 45 days from todays date");
$('#f10_'+row_id).val(" ");}
}
In the tabular form I call this function by having add this to the "custom attributes" field of the "START_DATE" column:
onchange="javascript:f_validate_sd(this);"
When I run my page and change the date, the message "NaN" as the third alert.
I've set up an example application here: DEMO
You can check it on apex.oracle.com by using these credentials:
Workspace: APEX_CHECKBOX
Username: appuser
PWD: demo