SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Name-case validation

    Hi all,

    To validate a name input field, I would like to prevent people from entering silly things like 'KEVIN' or 'kEvIn', etc... Let's stick to "normal" stuff like 'Kevin'... No problem here... Until we get people like 'McEwen', who find their names transformed into 'Mcewen'... I started throwing some code at these "exceptions", but meanwhile I started wondering whether I'm just re-inventing the wheel... Does any one know of (have handy!) a few lines of code to handle standard KEVIN->Kevin changes, while preserving things like McDonald, O'Connor, Aye-Mu, etc?

    Many thanks.

  2. #2
    SitePoint Evangelist spinmaster's Avatar
    Join Date
    Mar 2005
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would rather validate for alphanumeric characters, string-length, etc. I find it a bit silly to validate if the user entered his name as "Kevin" or "kevin" ...

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the user's name is to end up in a first-quality document and the production process is highly automated, it would look sooooooo much nicer if the name appeared as 'Kevin McBride' and not as 'KEVIN mcbride'... But, hey, that's just my aesthetic opinion...

    Where in Namibia, btw - I lived in Tsumeb and Windhoek for a while!

  4. #4
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can take a look at ucfirst()
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    frezno,
    thanks - I have already done that - it solves the KEVIN->Kevin cases, but not the exceptions that I mentioned above... thanks for the pointer, though.

  6. #6
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you're right.
    For names as O'Connor or Aye-Mu, regex might help, but for thos Mc's and Mac's etc there might be some problems.
    ok, as those are probabely the most common, you can check whether there's an Mc or Mac prefix of the name and then act according to what you want to achieve.

    it might get even more complicated if you have names which are made up of multiple words as often seen in the Netherlands, eg Piet van den Flochten
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  7. #7
    SitePoint Evangelist spinmaster's Avatar
    Join Date
    Mar 2005
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Azuleon
    If the user's name is to end up in a first-quality document and the production process is highly automated, it would look sooooooo much nicer if the name appeared as 'Kevin McBride' and not as 'KEVIN mcbride'...
    OK, in this case it might be different...

    Quote Originally Posted by Azuleon
    Where in Namibia, btw - I lived in Tsumeb and Windhoek for a while!
    cool stuff, I'm in Windhoek (Olympia)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •