2

I have a text field for inserting a postal code and I wanted the user's input to be uppercase for uniformity. I found a simple solution to just do text-transform: uppercase; however that also makes my placeholder in uppercase. Seems silly, but is there a way around this? Should I use javascript instead?

FIDDLE

Sir Celsius
  • 822
  • 8
  • 22
Laya302
  • 77
  • 2
  • 7

1 Answers1

4

This should work (in this example the class postalcode is applied to the postal code field):

.postalcode::-webkit-input-placeholder {
   text-transform: none;
}

.postalcode:-moz-placeholder { /* Firefox 18- */
   text-transform: none; 
}

.postalcode::-moz-placeholder {  /* Firefox 19+ */
   text-transform: none;
}

.postalcode:-ms-input-placeholder {  
   text-transform: none;  
}

.postalcode {
    text-transform: uppercase;  
}

See this fiddle:http://jsfiddle.net/u77z50db/1/

idmean
  • 14,540
  • 9
  • 54
  • 83
  • May want to check browser support, caniuse.com - not sure if there are any incompatibilities. – Michael Aug 20 '14 at 16:03
  • browser support is [**spotty**](http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css), and a final standard for this is not yet implented, so who knows what the future brings. – adeneo Aug 20 '14 at 16:06