Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Then you didn't place the code in the right location. It should go under the Validation tab, in the Custom Script option.
Copy link to clipboard
Copied
ok, got it now. Thanks. It works.
Copy link to clipboard
Copied
The script above will reject an invalid email address. Where did you place it?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 :).

