I created a simple markup such as this.
<html>
<head>
<head>
<body>
<input type="text" style="text-transform:uppercase" />
</body>
</html>
I was assuming that the browser will capitalize all inputs and indeed it was transformed
In my business layer, I am assuming that browser will send the form data on Upper case format also when I perform Post Method.
My problem is, when I receive the data at my Spring Controller, its not capitalize and I need to perform the capitalization myself.
Any idea?
text-transform:uppercase is not converting a string to uppercase you need to do that at the server side. You can see that if you copy a transformed text via cmd-c (strg-c) and paste it to a text document. The Text will be lowercase.
Take a look:
http://static.springsource.org/spring/docs/1.1.5/api/org/springframework/util/StringUtils.html#capitalize%28java.lang.String%29
Hope you are using the Spring-Framework.
CSS only affects the presentation. The text sent is still in lowercase. You do need to uppercase the string on the server side.
Copy the following code in your JS file:
// This function is used to change lower to upper case for the Input text
function cUpper(cObj)
{
cObj.value=cObj.value.toUpperCase();
}
After this, in your textbox's OnKeyup event put this:
return cUpper(this);
Save, upload and try.
You also could transform it on client side using js.
In your case I probably try to write own PropertyEditors.
See for details: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html
HTH