function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matt FolgerMatt Folger 

Make a text field CAPS only

Hi everyone.  

I'm trying to make a field where if a user enters "a91893b.e00" for example .  Even though they would input that, it should save or convert that to "A91893B.E00".
Best Answer chosen by Matt Folger
MissedCallMissedCall
Hello There,

If you don't want to take code route, here is an idea. Use 2 fields, Field 1 for user to input and Field 2 be a formula field with a formula UPPER(Field 1). You may want to decide what field needs to be displayed on the detail page layout and on edit mode.

All Answers

kaustav goswamikaustav goswami
Is the field in a VF page or is it in a standard detail page?

Thanks,
Kaustav
Gaurav NirwalGaurav Nirwal
Just add text-transform: uppercase to your styling, and then on the server side you can convert it to uppercase.

input {
  text-transform: uppercase;
}
Gaurav NirwalGaurav Nirwal
$('input[type=text]').keyup(function() {
    $(this).val($(this).val().toUpperCase());
});
Gaurav NirwalGaurav Nirwal
You can use the another command 

<script>
function caps(id)
{
    document.getElementById(id).value = document.getElementById(id).value.toUpperCase();
}
</script>


MissedCallMissedCall
Hello There,

If you don't want to take code route, here is an idea. Use 2 fields, Field 1 for user to input and Field 2 be a formula field with a formula UPPER(Field 1). You may want to decide what field needs to be displayed on the detail page layout and on edit mode.
This was selected as the best answer
Matt FolgerMatt Folger
@Kaustav:  It's a VF page.

@Matthews:  I'm a little confused where to plug-in the code that you provided.  I'll play around with it, but any advice much appreciated.

@MissedCall:  I like the way you think.  I'll try this out first to see if I can get around using code for this particular function.
Matt FolgerMatt Folger
Also, it is worthy of nothing that the field data can actually BE in lower case, but it just needs to DISPLAY in upper case.  (Paricular people I work with, I know.  *wink*).  I don't know if that changes anything.

Cheers all.
Matt FolgerMatt Folger
I'm using MissedCall's solution to the problem until the project lead gets back to me with what their demands are.