The CreatorCon Call for Content is officially open! Get started here.

Restrict special characters for catalog item variable

eshwar10
Giga Contributor

Hi Guys,

We have a requirement for a catalog item variable, in which it should restrict the

below special characters.

"(&[]~@|$^<>\*+=;?`')"   ---> inside quotes

I have written the below on change client script to achive this. The script is working

for all specail characters except for "\". Please provide your valuable inputs

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

          return;

    }

    // Dissallow special characters in application long name

    var specialCharRegex = /[~@|$&^<>\*+=;?`'())[\]]/;

  if(specialCharRegex.test(newValue)){

  alert('special characters are not allowed');

g_form.setValue('app_long_name','');

  }

}

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

Did you try var specialCharRegex = /[~@|$&^<>\\*+=;?`'())[\]]/;



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

Did you try var specialCharRegex = /[~@|$&^<>\\*+=;?`'())[\]]/;



Please mark this response as correct or helpful if it assisted you with your question.

It worked... Thanks!!!!!!!  


such a rookie mistake..


manikorada
ServiceNow Employee
ServiceNow Employee

Your regex need to be : [~@|$&^<>\*+=;?`'())[\]\\]



var specialCharRegex = /[~@|$&^<>\*+=;?`'())[\]\\]/;