2

Firstly I will start with a disclaimer. I am new to javascript.

This javascript is for ServiceNow. It is to stop certain staff members from raising a catalog item. It is working, however if a user was to use a capital, it would allow it.

I would like to make the script case insensitive.

I use a variable to define the email address:

var deny = "@email.com.au";

and then the variable is used in an if statement.

if (email.indexOf(deny) >= 0){
            g_form.showFieldMsg('variable', "email.com.au is not accepted" , 'error');
            g_form.setValue('variable',"");

How does one do this?

Cheers

Brendonius
  • 109
  • 3

3 Answers3

3

You can convert email to lowerCase and check index

if(email.toLowerCase().indexOf(deny) >= 0){
        g_form.showFieldMsg('variable', "email.com.au is not accepted" , 'error');
        g_form.setValue('variable',"");
LazyDeveloper
  • 599
  • 3
  • 8
0

Try the javascript function tolowercase and then do an indexof

Chiranjib
  • 1,763
  • 2
  • 17
  • 29
-1

Take the email array and convert all the content to lowercase using

for (int i = 0;i < email.length;i++) {
    email[i] = email[i].toLowerCase();
}

Then Compare