Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does text-transform in CSS not keep transform(uppercase) when submitted in form?

So if I have the code

.rsform-input-box {text-transform: uppercase;}

at the website http://www.thediabetesnetwork.com specific to our form fields at the bottom, you see the conversion to uppercase as you type, but the data is exported in the case you have typed it in. For example if I type Shane, it visually displays SHANE. On submit it will revert back to Shane in the database (at some point before).

My question is why does it do this and what are the work around options? My other option is

 function toUpCase()
{
document.getElementById("first").value=document.getElementById("first").value.toUpperCase();
document.getElementById("last").value=document.getElementById("last").value.toUpperCase();
document.getElementById("email").value=document.getElementById("email").value.toUpperCase();
}  
like image 691
Shane Avatar asked Nov 01 '12 22:11

Shane


People also ask

How do I force uppercase in CSS?

To make a block of text have all capital letters, use text-transform: uppercase in your CSS selector: text-transform: uppercase; The text-transform property accepts three possible values: uppercase: Sets each word to uppercase in a text element.

How do you make each word in a text start with a capital letter text-transform uppercase text-transform capitalize You Cannot do that with CSS?

The text-transform CSS property specifies how to capitalize an element's text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized.

Which CSS property controls the capitalization of text?

The text-transform property controls capitalization effects of an element's text.

Which property is used to transform the letters into uppercase?

The text-transform property is used to specify uppercase and lowercase letters in a text.


1 Answers

CSS is only for presentation of content. Therefore it does not change the values entered by the user, or what is submitted by the form to your database.

If your business requirement is to only accept all uppercase values into the database, it would be best to handle this in the back-end. For example: $input = strtoupper($input); if using PHP. Doing this on the back-end will ensure that your processing occurs even if the user has JavaScript turned off.

For a low-security requirement, your idea of handling it via JavaScript should work; just fire your toUpCase function before submittting the form.

From a usability standpoint - it's not really the user's job to worry about what goes into the database; and they probably don't need to know. But you'll make their life a little easier if you enforce the correct case behind the scenes each time you use those data points - at log-in for example.

like image 174
KatieK Avatar answered Sep 27 '22 23:09

KatieK