Email validation *@company.com

Community Alums
Not applicable

Hi,

I have a requirement that the email service catalog variable should accept only the *@company.com format, where * can be any name. It will not accept @gmail, @Yahoo, or any. Kindly help.

Regards

Suman P.

1 ACCEPTED SOLUTION

Rohit99
Mega Sage

Hi @Community Alums ,

You can create Regular expression in ( question_regex ) table. As mentioned below.

 Expresssion : ^[a-zA-Z0-9._%+-]+@testcompany\.com$ 

Rohit99_0-1731915795745.png


Now in catalog item select single line text as  a variable and in Type Specification section there is field called validation regex in that select regular expression which you created above in question_regex  table.

 

Rohit99_1-1731915981831.png

 

Please mark my response as correct and helpful if it helped solved your question.

 

Thanks,

Rohit Suryawanshi

View solution in original post

13 REPLIES 13

Community Alums
Not applicable

Runjay Patel
Giga Sage

Hi @Community Alums ,

 

You can use below script in onchange catalog client script, i am assuming email_id is variable in this case. You can replace with actual variable name.

 

   var email = g_form.getValue('email_id');

    if (email.indexOf('@runjay.com') == -1){
        g_form.clearValue('email');
    g_form.addErrorMessage('Add email containing @runjay.com');

}

 

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Community Alums
Not applicable

Hi @Runjay Patel,

 

What does this line explain? 

if (email.indexOf('@runjay.com') == -1){

Regards

Suman P.

If entered email does not contain (@runjay.com) then whatever is entered in email field for e.g 'Test@mail.com' it will clear that from email  variable
It is a sort of restriction for user to use @runjay.com in mail 

If my answer helped you in any way, then mark it as helpful or correct. This will help others finding a solution.

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj