Auto-convert field to uppercase
This is just a quick note for my future reference. I needed all items with the class “uppercase
” to be converted to uppercase, and I thought it would work with just some CSS:
.uppercase { text-transform: uppercase; }
This makes the items appear uppercase, but when the page is posted it actually sends the values exactly as the user typed. They’d type in “lower
“, it looks like “LOWER
” on screen, but gets posted as “lower
“.
In many cases I could just convert the value in my PL/SQL code, but in cases where I was using APEX tabular forms, I don’t know a simple way to intercept the values before the insert occurs.
To solve this I added this to the page’s Execute when Page Loads:
//the item looks uppercase but the internal value is still lowercase $(document).on('change', '.uppercase', function() { var i = "#" + $(this).attr("id"); $(i).val( $(i).val().toUpperCase() ); });
Or, even better, add this to the application’s global javascript file:
$(document).ready( function() { $(document).on('change', '.uppercase', function() { var i = "#" + $(this).attr("id"); $(i).val( $(i).val().toUpperCase() ); }); });
UPDATE: Interactive Grids
For interactive grids, you can still use this method. Put the class uppercase
in the Advanced / CSS Classes attribute (Note: this is different to the Appearance / CSS Classes attribute!). I would also set the Column Filter / Text Case to Upper for good measure.