- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 10:43 AM
Hi,
I have a requirement in the catalog form. The user is asked to mention the required email address. The variable type given here is 'Single Line Text'. So, I want the user to give the email address which ends with '@gmail.com' only and if that name is already taken, then it should say 'this email address is not available'.
How can I achieve this?
Thanks, in advance.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 11:02 AM
@2022_ServiceNow you can use catalog client script here on submit,
var email_= g_form.getValue('variable name').split('@'):
If (email_[1]=='gmail.com){
g_form.addErrorMessage('your error message to display to user on form');
return false;
}
Hope this will help you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 11:16 AM
Hello @2022_ServiceNow
Please refer to the below community posts.
You will get multiple client scripts that can be used to validate the email pattern string:
- How to validate Email field through Client script
- Email Validation script Required
- Email Validation for single line text field (Email ID)
- Is there a way to validate an email address
- Email validation client script (easy points)Now coming to the part where you need to validate if the email already exists or not.For this you need to write a script include, and call it via a glideajax in the client script.You can refer to the below post on how to write this script include:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 10:50 AM
Hello @2022_ServiceNow
Where are you going to check if the email id has been already taken?
Validating a single line text ending with @gmail.com should be pretty simple. But how will you check if that email id is available or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 11:01 AM
Hi,
I tried validating it using '^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@gmail.com.com' but not able to attach it in the variable. There's no option available of validation regex.
'@gmail.com' is an example. How about pointing it to the email address table and check whether it's available or not?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 11:16 AM
Hello @2022_ServiceNow
Please refer to the below community posts.
You will get multiple client scripts that can be used to validate the email pattern string:
- How to validate Email field through Client script
- Email Validation script Required
- Email Validation for single line text field (Email ID)
- Is there a way to validate an email address
- Email validation client script (easy points)Now coming to the part where you need to validate if the email already exists or not.For this you need to write a script include, and call it via a glideajax in the client script.You can refer to the below post on how to write this script include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 11:02 AM
@2022_ServiceNow you can use catalog client script here on submit,
var email_= g_form.getValue('variable name').split('@'):
If (email_[1]=='gmail.com){
g_form.addErrorMessage('your error message to display to user on form');
return false;
}
Hope this will help you.