Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Date format check using Javascript

gkthomasJan 19 2023

I am on Oracle apex 20.2. I have a form which save the data using Dynamic action. This form has a data field for start_date which I want to validate for DD-MON-YYYY format . Since the page not submit I cannot use the PL/SQL validation . So I have to use Javascipt to validate .
if the user enter anything other than a valid date it should stop and give error
So I used this function to check true or false in the javascript expression of the dynamic action. Somehow it always return false . I believe something wrong in the reg expression . Can somone help. Here is the function.

function checkDate(input) {
var dateFormat = /^(0?[1-9]|[12][0-9]|3[01])[\/\-](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[\/\-](\d{4})$/;
if(dateFormat.test(input.value)) {
return true;
} else {
console.log("False");
apex.message.showErrors(
{ type: "error", location: "page", message: "Invalid date entered. Please enter a valid date in the format dd-mon-yyyy.",
});
//alert("Invalid date format. Please enter a date in the format dd-mon-yyyy.");
P5_START_DATE.focus();
return false;
}
}

-- P5_START_DATE is a date picker

Comments
Post Details
Added on Jan 19 2023
2 comments
1,141 views