Skip navigation
Currently Being Moderated

Adding a "-" in Name Field for things like SS# or Phone#

Jul 20, 2012 7:48 AM

Tags: #phone #date #social #hyphens #autotab

This seems to be a simple question but a search just doesn't come up with anything.  maybe I don't know what to search for?

 

I'm trying to make fiels with the Hyphens "-" already in place for fields such as a Social Security Number or a Phone Number.

 

Phone Example:

A person types in 5555551212 and the field populates "555-555-1212" by automatically moving the cursor to the next blank space when that section of the field is full.

 

SS# Example:
A person types in 223233923 and the same thing happens with the dashes: 223-23-3923

 

I have the same question for Dates too, but with forward slashes:  07202012 would result in 07/20/2012.

 

It's probably a simple setting but I just don't know where to look.  Please help!

 

PS. I know how to change the "format" to force the user to ENTER the "-" or the "/", but what about automatically placing it in there for them or having it there aready?

 

PPS. I found the "Auto-Tab" Script here: http://www.planetpdf.com/developer/article.asp?ContentID=javascript_se tfocus_method_f&gid=6267  However, that forces me to Break up the field into 3 different fields and i'd like to avoid that if i could.

 
Replies
  • Currently Being Moderated
    Jul 20, 2012 7:54 AM   in reply to Neil-Kentucky

    It really is not that simple in an international world.

     

    Not all coutures use mm/dd/yy as their date format. Some use dd/mm/yy. And when one enters 1/10/09 is this January 10, 2009 or October 1, 2009?

     

    A 9 digit number is not only the SSN but it also the number of digits in the EIN, Employer Identification Number, used by both the U.S. IRS and U.S. SSA to identify an individual's employer. A 9 digit number is also used by many other countries but with a different location for the hyphen. Canada also uses a 9 digit string for its SIN number.

     

    Time also comes in some different format 12 and 24 and then there is the civilian and the military variation of the 24 hour format.

     

    With the use of the RegExp in JavaScript, one could write custom JavaScripts for the keystroke, format and validation actions that will insert the separator or allow the separator to be entered.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 20, 2012 11:57 AM   in reply to Neil-Kentucky

    Acumen Training is offering an eBook that has 3 chapters to just explain the basic. There are also a number of web sites that provide sample expressions and there is the a number of books available through Oreilly.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 20, 2012 12:37 PM   in reply to Neil-Kentucky

    You can use the following to format your SSnumber:

     

    //Put this in a document level script:

    function formatSSN (){

        var s = event.value

        var re = /^(\d{3})[ -]?(\d{2})[ -]?(\d{4})$/;

        if (re.test(s)) {

            var match = re.exec(s);

            event.value = match[1] + '-' + match[2] + '-' + match[3]

        }

    }

     

    // Put this in the Custom Format Script for the field(s) you want to format:

    formatSSN ()

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points