• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to verify proper tax id or ssn?

Explorer ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

I have a "TaxID" field on a form and I currently validate it with this script:

if (event.value) {
    if (/^\d{9}$/.test(event.value)==false) {
        app.alert("Invalid Tax ID!");
        event.rc = false;
    }
}

Which just checks to see if there are 9 digits entered.

I also want to allow entry with hyphens for either a TaxID (95-1234567) or SSN (123-45-6789) with the hyphens in either of the right places. How do I need to modify this script? (I really don't understand Regular Expressions).

TOPICS
How to , JavaScript , PDF forms

Views

327

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Apr 15, 2022 Apr 15, 2022

Hello @Terry Wysocki,

 

Give this a try...

if (event.value) {
    if (/^\d{9}$/.test(event.value)==false && (/^\d{2}\-\d{7}$/.test(event.value)==false && (/^\d{3}\-\d{2}\-\d{4}$/.test(event.value)==false))) {
        app.alert("Invalid Tax ID!");
        event.rc = false;
    }
}

 

Regards,

Mike

Votes

Translate

Translate
Advisor ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

Hello @Terry Wysocki,

 

Give this a try...

if (event.value) {
    if (/^\d{9}$/.test(event.value)==false && (/^\d{2}\-\d{7}$/.test(event.value)==false && (/^\d{3}\-\d{2}\-\d{4}$/.test(event.value)==false))) {
        app.alert("Invalid Tax ID!");
        event.rc = false;
    }
}

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

LATEST

Perfect, Mike! Works like a charm (But I still have to study RegEx!)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines