1. Overview
This document explains how to Allow only Numbers and Decimal Using Jquery in Oracle APEX.
2. Technologies and Tools Used
The following technologies has been used to achieve the shuttle type hide process.
- Oracle Apex
- Jquery
3. Use Case
Any requirement for Page Item Should allow only Number and Decimals. Please take a example of below screenshot.
4. Steps with Screenshot
Steps to be followed
Step 1: Create a region name as ‘Only Numbers’ and region type as Static Content
Step 2: Then, Create a Page item name as Numbers and type as Number Field.
Step 3: Then, Create a Button and name as Submit.
Step 4: Then, Paste the below code in Global Page, in the of section Execute when Page loads.
$(“.allow-decimal”).keypress(function (e) {
if(e.which == 46){
if($(this).val().indexOf(‘.’) != -1) {
return false;
}
}
if (e.which != 8 && e.which != 0 && e.which != 46 && (e.which < 48 || e.which > 57)) {
return false;
}
});
Step 5: In the Page Item, go to Advanced section Css Classes as ‘allow-decimal’ and Custom Attribute as ‘onfocusout=”this.value=Number(this.value).toFixed(2)”’ . You change the Decimal digit Which you want as Example: onfocusout=”this.value=Number(this.value).toFixed(4)”
Step 6: Finally, Save and Run the page.
Output:
Below screen shot shows the difference.