Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Conditional format text field based on Radio Selection - Email or Phone

Community Beginner ,
Jun 20, 2021 Jun 20, 2021

Copy link to clipboard

Copied

Hello,

 

I am trying to create a form where if the user selects either Email or Phone from the 'Email or Phone' radio button that the text field next to it would either validate an email address or a phone number (999) 999-9999.

 

My main difficulty is the script formating for the email address.  

 

Can anyone please help?

 

Drew

TOPICS
Edit and convert PDFs, How to, JavaScript, PDF forms

Views

745

Likes

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

Engaged , Jun 22, 2021 Jun 22, 2021
You are right, that doesn't make sense and it's even impossible to create a mask for the email address because the script can't know where to place the @ and the dot before the domain, but at least this script avoids typing an incorrect email address even if it is wrong  I corrected the script for the phone number format so we don't have to type parentheses, the space and the hyphen anymore. @+

Likes

Translate

Translate
Enthusiast ,
Jun 20, 2021 Jun 20, 2021

Copy link to clipboard

Copied

'Email or Phone' thats name of radio buttons?

What should format for email look like?

Likes

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
Community Beginner ,
Jun 20, 2021 Jun 20, 2021

Copy link to clipboard

Copied

Yes, that is the name.

 

The email form can be of any email.  It can be literally any type of email, but understandably it needs an "@" and a "."    

Likes

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
Adobe Community Professional ,
Jun 20, 2021 Jun 20, 2021

Copy link to clipboard

Copied

Why do you need to format an email address?

Likes

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
Engaged ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

Attached is a file where the format of the field is checked in accordance with the choice of 2 radio buttons: Phone Number or Email Address.
2 possibilities, with an alert message from a custom validation script or with the typing management from a custom keystroke script.
I found the email format on the web but as I am not a specialist, I don't know if it is 100% correct. The masks are explained on the pdf file.
@+

Likes

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
Adobe Community Professional ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

I understand using a validation script for an email address, but that's not the same as a Format script...

Likes

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
Engaged ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

For example, you can't type 2 dots in a row in an email address...

Likes

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
Adobe Community Professional ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

Again, that's validation, not formatting. Format means you take the value the user entered and change it to appear differently, according to some pattern. For example, if they enter "1234567890" you can have it automatically show up as "(123) 456-7890". Doing that with an email address doesn't make sense.

Likes

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
Engaged ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

LATEST

You are right, that doesn't make sense and it's even impossible to create a mask for the email address because the script can't know where to place the @ and the dot before the domain, but at least this script avoids typing an incorrect email address even if it is wrong 😉
I corrected the script for the phone number format so we don't have to type parentheses, the space and the hyphen anymore.
@+

Likes

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