Client script to check if email suffix starts or ends with '.fi' gmail.fi fi.gmail.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 07:58 AM
Hi,
Can someone help with the Client script syntax to check if email suffix starts or ends with '.fi' or 'fi.'
for example email suffix: 'ankita.ha@gmail.fi' or 'ankita.ha@fi.gmail.com'.
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 08:26 AM
Here is an example I used in a background script. Since I wrote out the variables, I know this syntax would work as long as you get get the variable to a string format for checking.
var str = "ankita.ha@gmail.fi";
var str2 = "ankita.h@fi.gmail.com";
var strSuff = str.substring(str.indexOf("@")+1,str.length);
gs.info(strSuff); //returns gmail.fi
var strSuff2 = str2.substring(str2.indexOf("@")+1,str2.length);
gs.info(strSuff2); //returns fi.gmail.com
if(strSuff.endsWith(".fi")){
gs.info("ENDS WITH .fi");
} else {
gs.info("DOES NOT END WITH .fi");
}
if(strSuff2.startsWith("fi.")){
gs.info("STARTS WITH fi.");
} else {
gs.info("DOES NOT START WITH fi.");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 09:04 AM - edited 06-27-2023 09:10 AM
function onCondition() {
var emailField = g_form.getValue('email_field'); // Replace 'email_field' with the actual field name for the email address
var emailPrefix = emailField.split('@')[0];
if (emailPrefix.endsWith('.fi')) {
// Email prefix ends with '.fi'
// Perform your desired actions or validations here
// For example, display a message or set a field value
g_form.addInfoMessage('Email prefix ends with \'.fi\'.');
} else if (emailPrefix.indexOf('.fi') !== -1) {
// Email prefix contains '.fi' but doesn't end with it
// Perform your desired actions or validations here
g_form.addInfoMessage('Email prefix contains \'.fi\' but does not end with it.');
} else {
// Email prefix doesn't contain '.fi'
// Perform your desired actions or validations here
g_form.addInfoMessage('Email prefix does not contain \'.fi\'.');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 08:32 AM
Hi @Ratish1
Thanks for your response!!
Instead of checking the email prefix, I want to check the email suffix if it ends with '.fi' or starts with 'fi.'
for example email suffix: 'ankita.ha@gmail.fi' or 'ankita.ha@fi.gmail.com'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 10:09 AM
Updated Code
function onCondition() {
var emailField = g_form.getValue('email_field'); // Replace 'email_field' with the actual field name for the email address
var emailSuffix = emailField.split('@')[1];
if (emailSuffix.startsWith('fi.')) {
// Email suffix starts with 'fi.'
// Perform your desired actions or validations here
// For example, display a message or set a field value
g_form.addInfoMessage('Email suffix starts with \'fi.\'.');
} else if (emailSuffix.endsWith('.fi')) {
// Email suffix ends with '.fi'
// Perform your desired actions or validations here
g_form.addInfoMessage('Email suffix ends with \'.fi\'.');
} else {
// Email suffix doesn't start with 'fi.' or end with '.fi'
// Perform your desired actions or validations here
g_form.addInfoMessage('Email suffix does not start with \'fi.\' or end with \'.fi\'.');
}
}