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).
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
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
Copy link to clipboard
Copied
Perfect, Mike! Works like a charm (But I still have to study RegEx!)