Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8481883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:40:53+00:00 2026-06-10T19:40:53+00:00

I have a form that when the user enters their name it automatically capitalise’s

  • 0

I have a form that when the user enters their name it automatically capitalise’s the first character of each, but when the user has a special character within their name such as ‘è’ then the code then precedes to capitalise the next character after.

EG:

Joesph Bloggs works fine but if I enter Joèsph Bloggs it actually outputs it as JoèSph Bloggs.

Notice the capital S in the middle of the name. The code I use at present is the following, any ideas how to prevent this?

Thanks

  capFirstLetters= function(str){
    return  str.toLowerCase().replace(/\b[a-z]/g, function(letter) {return letter.toUpperCase();});
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:40:55+00:00Added an answer on June 10, 2026 at 7:40 pm

    It’s because JS regexes aren’t unicode aware, sadly. A slightly better way of doing it would probably be:

    capFirstLetters= function(str){
        return  str.toLowerCase().replace(/(^|\s)[\S]/g, function(letter) {
            return letter.toUpperCase();
        });
    }
    

    This version of the regex would match a whitespace character or the start of the string, followed by a non-whitespace character.

    Note also that I have no idea what the behaviour here will be if people use non-extended-latin names, like those involving Chinese or Japanese characters. It is also unlikely to work correctly for languages which are read right-to-left (eg. Hebrew).

    This kind of thing is hard to get right and it may make more sense to use two separate fields for first and last name — or to simply leave user input the way it is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that the user submits and returns a result, but it
I currently have form that checks if a user has unsubmitted changes when they
I have a form field where a user enters contact information, including name, email,
I have a field that a user can input first and last name to
I have a form on a site that allows the user to enter their
I have a form where the user enters their database information and can click
I have a form that allows me to enter a user into my database.
I have a TextBox in a Windows Form that allows a user to enter
I have a form where a user can enter the number of students that
So I have a form that the user fills out, when submitted an new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.