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

PDF forms: email address field

Participant ,
Oct 28, 2022 Oct 28, 2022

Hello,

 

I am almost happy with the javascript instructions listed below and based on Creating email address format text box formatting:

var email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; if (event.value!=""){if (!email.test(event.value)){event.rc = false;app.alert("\"" + event.value + "\" is not a valid email address.");};};

However, the script above does not suppress a wrong email address. It only warns about the faulty format. I would like it to be more restrictive to force right email address. How could this be achieved?

 

Thanks

TOPICS
PDF forms
4.3K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Oct 28, 2022 Oct 28, 2022

You can use this as a Validation script:

 

if (event.value) {
event.rc = CBIsValidEmail(event.value);

if (!event.rc) app.alert("Invalid email address.");
}


Acrobate du PDF, InDesigner et Photoshopographe

View solution in original post

Translate
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
Community Expert ,
Oct 28, 2022 Oct 28, 2022

You can use this as a Validation script:

 

if (event.value) {
event.rc = CBIsValidEmail(event.value);

if (!event.rc) app.alert("Invalid email address.");
}


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
Participant ,
Nov 01, 2022 Nov 01, 2022

ok, interesting. I have replaced my script with yours. It does something similar (even through it is probably better). It recognizes an invalid email address and issues the warning "Invalid email address" when the provided email address is invalid. However, if I clicl "ok" in the pop up window showing the warning, the faulty email address is still kept in the box and it is still possible to save the pdf with the faulty email address. If we cannot do better than that, that's ok, but I was hopping for a more restrictive approach where the faulty email address could not be saved.

Translate
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
Community Expert ,
Nov 01, 2022 Nov 01, 2022

Then you didn't place the code in the right location. It should go under the Validation tab, in the Custom Script option.

Translate
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
Participant ,
Nov 01, 2022 Nov 01, 2022

ok, got it now. Thanks. It works.

Translate
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
Community Expert ,
Oct 29, 2022 Oct 29, 2022

The script above will reject an invalid email address. Where did you place it?

Translate
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
Community Expert ,
Oct 29, 2022 Oct 29, 2022

The plutonak script also rejects some valid addresses since it does not support more than 4 characters in domain name extension.


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
Participant ,
Nov 01, 2022 Nov 01, 2022
LATEST

I understand the question now. Yes, I initially misplaced the script under "Format → Custom → Run custom format script" instead of "Validate → Run custom validation script." The script in my initial message seems to work as well now but the one suggested by JR Boulay looks nicer :).

Translate
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