How would we use dynamic actions to perform a "not null" validation rather than when the user submits the page for processing? As the user is navigating through the fields, once in a required field, what would a dynamic action look like in order to force the cursor to never leave the field until the user enters something.
What I have done so far to achieve this (and I am very open to alternatives that are not as elaborate) is create a "p1_field_name is required" dynamic action that has the following properties:
"When" section:
- event = Lose Focus
- selection type and item = Item and p1_field_name
- condition is "is null"
"Advanced" section:
- event scope: bind
"Condition" section:
- dynamic action not conditional
"True Actions" section contains two actions:
- first action executes PL/SQL code as my condition as to whether the field should be required or not. if condition is not met, an explicit error is raised. the "stop execution on error" checkbox is checked. any fields referenced in the PL/SQL are entered into the "page items to submit" field.
- second action executes the following javascript: "setTimeout(function(){$('#p1_field_name').focus();}, 15);". i found this piece of code in the ApEx discussion forum which sets focus after a few milliseconds. "p1_field_name" is selected as the item in "Affected Elements" section.
Ok.... this is actually working wonderfully -- until I have two fields with their own versions of this dynamic action right next to each other. During this situation, the cursor immediately keeps shifting back and forth between the two fields because the dynamics actions appear to be battling it out between each other fighting over which one should have the cursor.
I've found the following discussion threads and examples of use, but nothing that has evidence from anyone saying they've accomplished this with dynamic actions
2161880
4497193
http://apex.oracle.com/pls/apex/f?p=41715:6
I've tried using the dynamic action "Set Focus" action, I've tried changing the "event scope" to "live" and "once," I've tried changing just about all the settings I can think of. After several trial-n-error attempts and lots of research in the discussion forum, the above is the closest I've gotten to getting client-side "not null" validation. Any one out there done this type of thing? Am I making it substantially harder than it needs to be?
Shane.