1. Overview

We know some time user might enter a wrong date while entering, to avoid this we can create some dynamic actions and validation to notify user have entered wrong date format . Suppose you want to notify that you have entered wrong date format and it should throw error message on the time of creating ,  you may use this method and find is any invalid date has entered ,if yes then change into a valid date format .,The following steps will help you to throw error message near to the page item.

 

2. Technologies and Tools Used

The following technology has been used to achieve the same.

  • Javascript
  • PLSQL
  • Oracle Apex

 

3. Use Case

Suppose you want to notify that you have entered wrong date format and it should throw error message before submitting the page ,  you may use this method and find is any invalid date has entered ,if yes then change into a valid date format .

 

4. Architecture 

Following steps explains in detail,

Step 1:  Create a new blank page.

Step 2:  Create a new region

Under identification you can give the title

Step 3: Create Page Items which need to be a date.

 

Step 4: Add Format Mask and Value placeholder.

 

Step 5: Now Create a following script on Global page.

<script>

function validateDate(date){

var regex=new RegExp(“([0-9]{4}[-|/](0[1-9]|1[0-2])[-|/]([0-2]{1}[0-9]{1}|3[0-1]{1})|([0-2]{1}[0-9]{1}|3[0-1]{1})[-|/](0[1-9]|1[0-2])[-|/][0-9]{4})”);

var dateOk=regex.test(date);

if(dateOk){        return 1;

}else{       return 0;

}

}

</script>

Step 6: Create a Dynamic action to through Error when entering wrong date format.

var date_from      = $v(‘P6_FROM_DATE’);

 

if(validateDate(date_from)== 0) {

apex.message.clearErrors();

if ( $(“#P6_FROM_DATE_error”).length == 0) {

 

apex.message.showErrors([

{

type:       “error”,

location:   [ “page”, “inline” ],

pageItem:   “P6_FROM_DATE”,

message:    “Please enter the date in valid Date Format.”,

unsafe:     false

}

])

}

}

else{

apex.message.clearErrors();

}

 

 

Step 7:  Now Refresh front page and enter wrong date format.

 

 

5. Screen Shot

Output

Invalid Date format:

Recent Posts

Start typing and press Enter to search