Auto-convert field to uppercase

style="text-transform: uppercase;" onKeyUp="this.value=this.value.toUpperCase();"

This is the simple method, please copy the code and paste into custom attributes and then run the page.

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
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() {
var i = "#" + $(this).attr("id");
$(i).val( $(i).val().toUpperCase() );


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s