Abdirizak Obsiye
Abdirizak Obsiye

Reputation: 285

Oracle apex, disable submit page button on condition where evey must have field is null, how?

How would you give a button an id? How would you affect the attributes of a button disabling and enabling it depending if field are empty or not. I wouldn't like to use a dynamic action. I was thinking JavaScript. Any help would be helpful. Thank you.

Upvotes: 0

Views: 3081

Answers (2)

Santhosh Jose
Santhosh Jose

Reputation: 587

To add an id to a button in Oracle Apex, click on the button. On the right-hand side where you set the properties for the button, find a property called 'Static ID'. Enter the id you want in here.

For the text field, the name of the text field is the id.

Once these are in place, you can add the code that @Lajos has shared above (replacing the ids with your own ids), into the "Function and Global Variable Declaration". You can find this box in the JavaScript section in the Page properties. Ensure that you remove the <script></script> tags from the code.

Upvotes: 1

Lajos Arpad
Lajos Arpad

Reputation: 76551

This is how you give an id to a button:

<input type="button" id="your-id" value="My Button">

Let's suppose the field we are talking about is

<input type="text" id="another-id">

This is how you enable/disable the button while you type some text into the input (you need to write your Javascript code as the inner text of a <script> tag):

<script type="text/javascript">
    $(function() { //Load event
        $("#another-id").change(function() { //change event
            if ($(this).val().length > 0) { //It is not empty
                $("#your-id").removeAttr("disabled");
            } else { //It is empty
                $("#your-id").attr("disabled", true);
            }
        });
    });
</script>

Upvotes: 1

Related Questions