Skip to main content
Participant
February 14, 2018
Answered

arbitrary mask for an email address of random length

  • February 14, 2018
  • 2 replies
  • 4474 views

I would like to create an email address that allows random lengths before and after the @ symbol.

This topic has been closed for replies.
Correct answer try67

I understood that, and the RegExp I provided will do it.

Use this code as your field's custom validation script:

if (event.value) {

    event.rc = /^.+@.+$/.test(event.value);

}


If you want to make sure it includes a period in the second part use this, instead:

if (event.value) {

    event.rc = /^.+@.+\..+$/.test(event.value);

}

2 replies

Participant
March 22, 2020

Thanks for this.

try67
Community Expert
Community Expert
February 14, 2018

You can't use an arbitrary mask for that. You need to use a custom validation script.

The most basic validation would be against the RegExp /^.+@.+$/.

Participant
February 14, 2018

I guess I should have been more specific.  I was wanting to create a field with a script that would validate and email address of random length.  i.e., verifying _________@_____.____ where the underline areas are any character/length and the "@" and "." are known and expected for validation.  Thanks.  Not sure how to implement RegExp /^.+@.+$/

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 14, 2018

I understood that, and the RegExp I provided will do it.

Use this code as your field's custom validation script:

if (event.value) {

    event.rc = /^.+@.+$/.test(event.value);

}


If you want to make sure it includes a period in the second part use this, instead:

if (event.value) {

    event.rc = /^.+@.+\..+$/.test(event.value);

}