Copy link to clipboard
Copied
I am attempting to have a Radio button checked based on text in a text field. The text field is named "E-mail Address", the Radio Button Group is named "Designation" and has three choice, "Military", "Civilian", or "Contractor". Our email addresses have a unique component to them based on the designation of the person, so they always have, and only one, of the below text strings.
- If the E-mail Address field contains ".mil@", check the "Military" Radio Button,
- If the E-mail Address field contains ".civ@:, check the "Civilian" Radio Button,
- If the E-mail Address field contains ".ctr@:, check the "Contractor" Radio Button.
(If they don't have any of these text strings, no choice is checked in the Designation Radio Button and they will manually check the correct box, that is okay.)
Because these are email addresses, there will always be text before and after the specific text string I am validating against, but there is no defined pattern to the text.
I have it working to point that if only ".mil@", ".civ@", or ".ctr@" is entered into the E-mail Address field (no other text in the field) then the correct Radio Button is checked. However, if any additional text is entered into the E-mail Address field, it doesn't work. I can't figure out the wildcard charactor and assocated formatting.
How do I add a wildcard character so that the Validation works with any text before and after the specific text string I am validating against? Thank you in advance for your assistance.
Here is the JS code I entered into the JS editor of the Validate tab as a Run custom validation script of the E-mail Address text field):
if( event.value == ".mil@")this.getField("Designation").value = "Military";
if( event.value == ".civ@")this.getField("Designation").value = "Civilian";
if( event.value == ".ctr@")this.getField("Designation").value = "Contractor";
Copy link to clipboard
Copied
As Validate script of email field use this:
var str = event.value;
var pattern = /\.(mil|civ|ctr)@/;
var matchResult = str.match(pattern);
if(matchResult){
var matchedString = matchResult[0];
if(matchedString === ".mil@")
this.getField("Designation").value = "Military";
else if(matchedString === ".civ@")
this.getField("Designation").value = "Civilian";
else if(matchedString === ".ctr@")
this.getField("Designation").value = "Contractor";}
Copy link to clipboard
Copied
As Validate script of email field use this:
var str = event.value;
var pattern = /\.(mil|civ|ctr)@/;
var matchResult = str.match(pattern);
if(matchResult){
var matchedString = matchResult[0];
if(matchedString === ".mil@")
this.getField("Designation").value = "Military";
else if(matchedString === ".civ@")
this.getField("Designation").value = "Civilian";
else if(matchedString === ".ctr@")
this.getField("Designation").value = "Contractor";}
Copy link to clipboard
Copied
Worked perfectly, thank you!

