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?
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";
Perfect. Thank you! I would have struggled for the rest of the day on this.
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 "firstname.lastname@example.org". All good so far.
But wait, you remembered that your email address is actually email@example.com !
No problem, you go back to the field and fix it. What happens when you exit the field?
Oops, it's now "firstname.lastname@example.org@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.
Yes, I made a mistake, use it as a "Custom format script".