Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Costumer registration: First letter in caps


Recommended Posts

As the title says.


I find that costumers sometimes do not write their names with the first letter in uppercase. I find it a bit unprofessional looking when customers login or place an order and read e.g. john doe instead of John Doe.


I did some searching on the forums but I didn't get any result.


I know a fair amount of PHP and I can manually edit the code so that where the data is put into the database a run a ucfirst() (or whatever is needed) on it.

But it's faster if someone has already fixed this and/or knows where I can find this specific contribution/solution.



Link to comment
Share on other sites

This may help: Click Me


Except you'd probably be dealing with this code:


	$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);

And change it to:


	$firstname = ucfirst( tep_db_prepare_input($HTTP_POST_VARS['firstname']) );
$lastname = ucfirst( tep_db_prepare_input($HTTP_POST_VARS['lastname']) );

As always it's a good idea to backup any file before making edits.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.


"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -


"Headers already sent" - The definitive help


"Cannot redeclare ..." - How to find/fix it


SSL Implementation Help


Like this post? "Like" it again over there >

Link to comment
Share on other sites

We do this with Javascript on our site smile.gif The advantage is that for people who have names starting with lower case letters (there are a few!) they can correct it when it changes (it will only upper case the name once)


<script language="javascript"><!--
var firstname = 1;
var lastname = 1;

function updateCase(theField){
theField.value = theField.value.toLowerCase();
fVal = theField.value.replace(/\b(\w)/g, function(c){return c.toUpperCase()});
if(fVal != theField.value){
	theField.value = fVal;

function properCase(theField, theVar){
if (theVar == 'firstname' && firstname) {
	firstname = 0;
if (theVar == 'lastname' && lastname) {
	lastname = 0;


Lower down the page:


		<td class="main" width="140"> First Name:</td>
		<td class="main"> <input type="text" name="firstname" id="firstname" onblur="properCase(this, 'firstname')"> <span class="inputRequirement">*</span></td>

		<td class="main" width="140"> Last Name:</td>
		<td class="main"> <input type="text" name="lastname" id="lastname" onblur="properCase(this, 'lastname')"> <span class="inputRequirement">*</span></td>

Link to comment
Share on other sites

Also there are at least 2 contributions for this.

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile


Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.


For links mentioned in old answers that are no longer here follow this link Useful Threads.


If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...