1 Reply Latest reply on Mar 7, 2007 12:42 PM by c_wigginton

    handling last name foramt

    HandersonVA Level 1
      Hello, the letter that needs to be generated has a "TO" section and a person's last name should be started with "uppercase" and rest of them is printed "lowercase", but some cases are treated differently. (Users need to input the last name before they generate the letter).
      But they input too many different formats of last name and it is a nightmare to catch those formt to print out the first letter to be uppercase and some cases the second letter should also be capital..
      For example, last name O'Nell. In this case, it should be print out "O" and "N" all capital. Some has Hong-Sang.
      Look at these last name that users entered.
      DAVIS JR,
      St. Andrews
      HALL JR.
      MOORE 11
      Santos, Jr.
      O NEILL
      omg, I have no idea how to print out thoses last name in a proper format on "TO" section on the letter.
      maybe I need to prevent them to inputting a wrong last name format, but what are the right last name format then?
      Does ColdFusion has something that can handle this situation? please advise me.

        • 1. Re: handling last name foramt
          c_wigginton Level 1
          Tough problem. You might have to rely on the user to correct. Maybe use AJAX to pre-process a few different formats. It would be a slight annoyance on the user's part, but it looks like it's a requirement for your application.

          First, I'd consider locking down the client with Javascript and disable the ability to enter a numeric character, that would knock off the 11. Most people would revert to II if they couldn't type a 11.

          Break it down as follows through a set of rules and then iterate over the rules. If you find you missed a rule, a rule framework would make it easy for you to add another condition:

          Rule1: if first letter cap and rest lowercase, and no spaces, last name ok your option if you just want to process it normally.

          Rule2: If ALL CAP no spaces, Cap first, lower rest add as option

          Rule 3: If multiple words, cap first lower rest of each word and add as option

          Rule 3: If first letter begins with O, process rule 2, add a comma, add a space, add rest add as option, then again you have to worry about (i.e. Patrick McHenry), You could also create a lookup table of Irish surnames ( http://www.ireland-information.com/heraldichall/irishsurnames.htm), grab the last name, strip the spaces and then perform a find against the 100 Irish surnames (link above), etc...

          Rule 4: etc...

          Then pop up a dialog Where the user chooses the correct format from the option list, or has the option of manually correcting the choice, such as a series of radio buttons and a text box.