Skip to main content
Participant
January 26, 2021
Answered

Forms - Email address field

  • January 26, 2021
  • 2 replies
  • 3459 views

I'm creating a form that has an email address field. Form users will all have addresses at the same domain. I'm struggling with a way to make the domain show up after typing the first part of the email address.

 

For instance, I'd like to be able to type "myemail" and then have "@company-name.com" automatically append to the text.

 

I've tried using an arbitrary mask, but that either doesn't work, or I'm typing the wrong syntax. Can anyone point me in the right direction?

This topic has been closed for replies.
Correct answer JR Boulay

To use the Arbitrary mask you must know the exact number of caracters to be entered before the @

 

Remove the Arbitrary mask and use this as a Validation script Custom Format script :

 

event.value = event.value + "@company-name.com";

 

 

2 replies

JR Boulay
Community Expert
Community Expert
January 27, 2021

Yes, I made a mistake, use it as a "Custom format script".

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
January 26, 2021

To use the Arbitrary mask you must know the exact number of caracters to be entered before the @

 

Remove the Arbitrary mask and use this as a Validation script Custom Format script :

 

event.value = event.value + "@company-name.com";

 

 

Acrobate du PDF, InDesigner et Photoshopographe
Brad5CAFAuthor
Participant
January 26, 2021

Perfect. Thank you! I would have struggled for the rest of the day on this.

try67
Community Expert
Community Expert
January 26, 2021

Does the value of the field need to change or just the way it is displayed?

If the latter then I would recommend using this code as a Format script, not Validation.

Why not? Try the following:

Enter something into the field and then exit it. Let's say you entered "joe".

The field now shows "joe@company-name.com". All good so far.

But wait, you remembered that your email address is actually joe1@company-name.come  !

No problem, you go back to the field and fix it. What happens when you exit the field?

Oops, it's now "joe1@company-name.com@company-name.com"... The script adds the domain each time you edit the field's value, no matter what it already shows.

To make it work correctly you would need to not just add the domain, but also remove it if it already exists, or use a Format script. I would also add a condition not to add the domain suffix in case the field is empty.