Working with disabled textfields

Von Tobias Arnhold 1.21.2015
In APEX you have the possibility to disable text fields.
Unfortunatelly you can not submit those fields after the value was changed by a dynamic action or some javascript code.
Out of a security point of view in most cases this makes sense.

In case you do have to change the value during the runtime and need to send it to the database. You have to pretend that the elements are disabled. Fortunately it is quite easy to do so.

1. First all textfields must be enabled.
2. Now create two dynamic actions using the following code snippets:
2.1 Disable all necessary fields "after page load":
$('#P1_ITEM_NAME').attr('disabled', 'disabled');
2.2 Enable all necessary fields "before page submit":
$("#P1_ITEM_NAME").removeAttr("disabled");

Post Tags:

4 Comments " Working with disabled textfields "

Anonymous

$('#P1_SYSTEM_NAME').prop('disabled', true) or $('#P1_SYSTEM_NAME').prop('disabled', false) could also be used

Marko Gorički 21 January, 2015 12:11

I've posted about this also:
http://apexbyg.blogspot.com/2013/06/saving-values-of-disabled-items-to.html

There's another solution, you can also put readonly="readonly" in HTML Form Element Attributes property of text items. In this case, you can change value dynamically but the end user can't.

As you said in both cases it's security issue because advanced users can change it using FireBug or some other tool.

Marko Gorički 21 January, 2015 12:12

I've posted about this also:
http://apexbyg.blogspot.com/2013/06/saving-values-of-disabled-items-to.html

There's another solution, you can also put readonly="readonly" in HTML Form Element Attributes property of text items. In this case, you can change value dynamically but the end user can't.

As you said in both cases it's security issue because advanced users can change it using FireBug or some other tool.

Annelize Freeman 14 November, 2017 13:27

Marko, have you got this to work on Date Picker fields?

I have 5 mandatory fields on my form, all set to disabled by a dynamic action. For some reason, this is the only column that still prompts for a value after I've removed disabled on a 'Before Page Submit' DA using either $(':disabled').removeAttr('disabled'); or enabling each field indiv.