473,729 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function to capitalise each word

To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter after a
space or hyphen.

So many users seem to think that just because they are online they can
use names like "mr john smith" and so I have to manually change them.
--
Nige

Please replace YYYY with the current year
ille quis mortem cum maximus ludos, vincat
Jul 20 '05 #1
13 6382
Lee
Nige said:

To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter after a
space or hyphen.

So many users seem to think that just because they are online they can
use names like "mr john smith" and so I have to manually change them.


There is no way of knowing which letters in a person's name
should be capitalized. If your user chooses to be called
"john smith", why do you feel that you have to change it?

Jul 20 '05 #2
Nige wrote:
To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter
after a space or hyphen.

So many users seem to think that just because they are online they can
use names like "mr john smith" and so I have to manually change them.


<p style="text-transform:capit alize">mr john smith</p>


Jul 20 '05 #3
On 10 Nov 2003 10:07:21 -0800, Lee <RE************ **@cox.net> wrote:
Nige said:

To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter after a
space or hyphen.

So many users seem to think that just because they are online they can
use names like "mr john smith" and so I have to manually change them.


There is no way of knowing which letters in a person's name
should be capitalized. If your user chooses to be called
"john smith", why do you feel that you have to change it?


Or people such as "Aravinda de Silva" who you'd be getting the name
completely wrong if you use De.

Jim.

--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #4
Nige hu kiteb:
To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter
after a space or hyphen.

So many users seem to think that just because they are online they can
use names like "mr john smith" and so I have to manually change them.


In the case of my surname (van-de-l'Isle), this would result in an
incorrect capitalisation. Banks have lost my account over this kind of
thing. Then there was the time the bank's computer code decided that a
hyphen ended the surname string. Boy was I pished off over that one.

--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #5
Fabian hu kiteb:
Nige hu kiteb:
To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter
after a space or hyphen.

So many users seem to think that just because they are online they
can use names like "mr john smith" and so I have to manually change
them.


In the case of my surname (van-de-l'Isle), this would result in an
incorrect capitalisation. Banks have lost my account over this kind of
thing. Then there was the time the bank's computer code decided that a
hyphen ended the surname string. Boy was I pished off over that one.


If you really want to check this kind of thing, you could have the
submit linked to a function that gives the user a lst chance to edit
that field before submitting.

"The name field appears to have unusual capitalisation. Is this correct,
or do you want to go back? Submit/Edit"

But forcing this field into your idea of correct will really annoy some
people.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #6
Jim Ley wrote:
On 10 Nov 2003 10:07:21 -0800, Lee <RE************ **@cox.net> wrote:
Nige said:
To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter
after a space or hyphen.

So many users seem to think that just because they are online they
can use names like "mr john smith" and so I have to manually change
them.


There is no way of knowing which letters in a person's name should be
capitalized. If your user chooses to be called "john smith", why do
you feel that you have to change it?


Or people such as "Aravinda de Silva" who you'd be getting the name
completely wrong if you use De.


And yet with my last name I prefer DeFaria.

If the user cannot spell their own name then IMHO, that's their problem
- not yours!
--
Why do people ask "Can I ask you a question?".... Didn't really give me
a choice there, did ya sunshine?

Jul 20 '05 #7
In comp.lang.javas cript, Lee wrote:
If your user chooses to be called
"john smith", why do you feel that you have to change it?


I used it as an example, the main thing I want to change is their
address: "21 park street, birmingham" to "21 Park Street, Birmingham"
--
Nige

Please replace YYYY with the current year
ille quis mortem cum maximus ludos, vincat
Jul 20 '05 #8
Nige hu kiteb:
In comp.lang.javas cript, Lee wrote:
If your user chooses to be called
"john smith", why do you feel that you have to change it?


I used it as an example, the main thing I want to change is their
address: "21 park street, birmingham" to "21 Park Street, Birmingham"


Then you picked just about the worst possible example. Many people are
sensitive about having their name mispelt. For your company to mispell a
customer's name when they entered it correctly is a surefire way to lose
that customer. And that kind of customer tells ten people all about it.
Unless they are online, in which case they tell a hundred.

--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk
Jul 20 '05 #9
Fox

emulating php ucwords function:

function
ucwords(str)
{

return str.replace(/\b\w/gi,
function(c,i,s) {
return c.toUpperCase() ;
});

}

OR (more js-like)

String.prototyp e.ucwords = function(){
return this.replace(/\b\w/gi, function(c,i,s) { return
c.toUpperCase() ; });
}

example:

var properAddress = rawaddress.ucwo rds();

all problems mentioned in this thread will still exist... handle with care.

Nige wrote:

To save me re-inventing the wheel, does anyone have a function to
capitalise each word in form data? I was thinking along the lines of
capitalise the first letter of the string, then any other letter after a
space or hyphen.

So many users seem to think that just because they are online they can
use names like "mr john smith" and so I have to manually change them.

--
Nige

Please replace YYYY with the current year
ille quis mortem cum maximus ludos, vincat

Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3154
by: Derek Rhodes | last post by:
using Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32 OK, I have a recursive function that should return a list, but doesn't <start session> def test(word): if type(word) == str:
10
3214
by: Nige | last post by:
Repost - as some readers took got sidetracked. To save me re-inventing the wheel, does anyone have a function to capitalise each word in form data? I was thinking along the lines of capitalise the first letter of the string, then any other letter after a space or hyphen. So many users seem to think that just because they are online they can use addresses like "8 brown road, chatham, kent" and so I have to manually change them.
7
6817
by: John Aspinall | last post by:
Hi, Can someone please tell me how to capitalise all words in a string that are seperated by spaces. The string is variable and not the same every time hence I cant use the Ucase function as I wont know the exact position of the start of each word. Cheers....John
11
2712
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
4
1937
by: Christine | last post by:
I am having the strangest problem. I use the Date function in several of my forms and modules in an Access 2000 mdb. Lately, wherever in my code (in this one mdb) I use the Date function, it changes to date (lower case vs proper case). I can fix this very temporarily by reconstructing the database (importing all objects to a new mdb) or using the decomplie option to open it. But in either case, once I compile it reverts back to lower case....
6
2681
by: Ryan Muller | last post by:
My company just upgraded from Access 97 to Access 2003 today and we are having some issues in a database that generates a Word document from information selected in a form. Here is the code we were using without issue previous to the switch: 'Start Word and create a new doc from the template Set objWord = CreateObject("Word.Basic") objWord.AppMaximize "Microsoft Word", 1 objWord.FileNew Template:=StrTemplPath & "letter.dot"
0
2345
by: serkan | last post by:
Guys, I am trying to get this password reset functionality wor for me but I am not successful at all. Please somebody help me. I get "Your password could not be reset - please try again later" so I think the get_random_word function is not working right. Here are the scripts: This is the script after the user enters his/her userid. <?php require_once("bookmark_fns.php"); // creating short variable name $username = $_POST;
3
2027
by: Russell | last post by:
Hey, ok i have numerous tables to search through for a 'site search'. some of the searchble fields have html embeded within so after some quick referencing, saw I can use the regExp function to strip out all the HTML leaving only the raw text. (done and works a treat) My issue is:
4
1452
by: hanseymoon | last post by:
Dear newsgroup: I've got this long function, which works good overall to spell check words from a dictionary and I am not in a position to replace it. Can someone please see where or how it might be chopping up words like: don't. It brings them back as: 't, chopping off the "don" before the apostrophe. I've looked over the whole situation and ran many $string tests....and it appears to be narrowed it down to this. I may be wrong and...
11
1777
by: Daniel T. | last post by:
The function below does exactly what I want it to (there is a main to test it as well.) However, I'm curious about ideas of making it better. Anyone interested in critiquing it? void formatText( const string& in, int charsPerLine, int lines, vector< string >& out ) { out.resize( 1 ); out = ""; int prev = 0;
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.