Allow only integers in page item Oracle APEX

Using JavaScript APEX page item can be designed to allow only numbers and decimals, restricting non-numeric characters. 

Steps to implement
  • Select the page item for which you want to allow numeric input, including decimals.
  • In the “Properties” section for that page item, go to the “Advanced” section and find the “Custom Attributes” field.
  • In the “Custom Attributes” field, add the following JavaScript code:
onkeypress="return (event.charCode >= 48 && event.charCode <= 57) || event.charCode === 46"

This JavaScript code allows keypress events for characters with charCodes between 48 (0) and 57 (9) (numeric digits) and also allows the decimal point with charCode 46.

 

Now, users will be able to input both integer and decimal numbers in the page item, and non-numeric characters will be restricted.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *