6 Replies Latest reply: Sep 10, 2010 1:39 PM by jweizenblut RSS

    Validate SSN

    meem23 Community Member

      Hi,

      I've been looking around a bit to find a solution to by problem, but can't seem it find it.  I want to set a script to validate an SSN entry.  If the user exits the field and they have entered it incorrectly, I want it to error and then set the focus back to that field.

       

      I set my patterns as

      Edit Pattern:  text{999-99-9999}|text{999999999}

      Display and Validation Patterns: text{999-99-9999}

       

      and I attempted to set the script as follows:

       

      if

       

       

       

      (this.rawValue =! text{999-99-9999}||text{999999999})

      {

      app.alert("Please enter SSN as 999-99-9999 or 999999999");

      xfa.host.setFocus("SSN");

      }

       

      Can someone direct me to a post or help with my script.

       

      Thanks!

        • 1. Re: Validate SSN
          Srini Dhulipalla Community Member

          Here is a sample file for you..

          https://acrobat.com/#d=lBhs6fLfzaWMUCMd0R5Vvg

           

          Let me know if this helps..

           

          Thanks

          Srini

          • 2. Re: Validate SSN
            meem23 Community Member

            I'm not able to open your sample without updating my flashplayer and unfortunately our IT doesn't want us to upgrade yet.

            • 3. Re: Validate SSN
              Srini Dhulipalla Community Member

              Send a test email to LiveCycle9@gmail.com (OR) send a personal message in the forum, so I can send the file to your email..

               

              Thanks

              Srini

              • 4. Re: Validate SSN
                jweizenblut

                Can you also send me information on how to do this?

                • 5. Re: Validate SSN
                  meem23 Community Member

                  Hi,  This is what I used. 

                   

                  1) Create a Script Object with the name "globalFunctions".

                  2) Place the below script in the script object..

                   

                  function isValidSSN(SSNstr){

                  var ssnChar = "-";

                  var strMessage ="";

                  var pos1=SSNstr.indexOf(ssnChar);

                  var pos2=SSNstr.indexOf(ssnChar,pos1+1);

                   

                  var strFirst=SSNstr.substring(0,pos1);

                  var strSecond=SSNstr.substring(pos1+1,pos2);

                  var strThird=SSNstr.substring(pos2+1);

                  //xfa.host.messageBox("First = " + strFirst + " Second = " + strSecond

                  + " Third = " + strThird);

                  if(strFirst.length !=3 || strSecond.length != 2 || strThird.length !=

                  4){

                     

                    return "Not valid SSN";

                  }

                  else

                    return "Valid SSN";

                   

                  }

                   

                  3. Place 2 text Fields on your form.

                   

                  4. In the properties of one Text Field, place the below pattens.

                   

                      Display: text{999-99-9999}|text

                   

                      Edit: text{999-99-9999}

                   

                     In the Change event of the field, place the below script.

                   

                  if (xfa.event.change.match(/[0-9\-]/) == null)

                       xfa.event.change = "";

                   

                  In the Exit event of the field, place the below script.

                   

                  var strReturnMessage = globalFunctions.isValidSSN(this.formattedValue);

                   

                  if(strReturnMessage != "Valid SSN"){

                  xfa.host.messageBox("Please enter SSN as 999-99-9999 or 999999999");

                  xfa.host.setFocus(this);

                  }

                  • 6. Re: Validate SSN
                    jweizenblut Community Member

                    Thank you so much.

                    If I may, got a question on how to do 2 things.

                    1st. Can I create a button in the PDF that when I click on it, will open

                    Internet Browser and go to URL I specify?

                    2nd. Same as above, but can I have it do a form post to the URL I specify

                    and post certain values only instead of the whole form? Then, display the

                    results on the Internet Browser. The PDF remains open in the background.

                    If you can point me in the right direction, I would really appreciate it.

                    Thanks!