Press "Enter" to skip to content

Oracle Apex: Allow Only Integer Value Using jQuery

In this tutorial, I will show you how you can allow only integer value to be entered into a number field in Oracle Apex using the jQuery. Follow these steps:

1. Specify a Class for the Numeric Field

In Oracle Apex, open your page and select the field for which you want to allow only integer values. Then in the Advanced section specify a class allow-integer in CSS Classes field as shown in the below image:

Add a CSS class to a field in Oracle Apex.

2. Add the jQuery Code

Now add the following jQuery code to the Execute when Page Loads section of the page. Below are the code and screenshot for your reference:

 $(".allow-integer").bind("keypress", function (e) {
          var keyCode = e.which ? e.which : e.keyCode               
          if (!(keyCode >= 48 && keyCode <= 57)) {
            return false;
          }else{
          }
      });

Add jQuery code to a Page in Oracle Apex.

Additionally, if you want to specify a particular length of the digits the user can enter, that you can do it by going to the Validation section of the field and specify the maximum length in characters in the input field.

You can specify the same class allow-integer to each field in your page for which you want to allow only integer values.

Now save the changes and run the page to test. It will allow only integer values for that numeric field.

In the next tutorial, I will show you how to allow numbers with a decimal point (Float values) in a field in Oracle Apex using jQuery.

Related tutorials:

Vinish Kapoor

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. foxinfotech.in is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

Comments are closed.