Regular Expression not Working in Service Portal

vijay39
Giga Expert

Hi all,

I have written a client script, which does not allow special characters like below

var value   = /^[a-zA-Z.1-9-_]+(\s+[a-zA-Z] )?$/.test(newValue);

In Service Now main UI, it is working good, like if i give space before the input of a field, it is showing alert not to enter special characters, but in service portal, that alert is not poping up. where could be the problem? Can someone help me on this?

Note: UI type is selected All

and Scope is also Global

 

 

Thanks in advance

Vijay

1 ACCEPTED SOLUTION

Hi there,

Something like below should work. Just tested on Madrid with the Question Regular Expressions. Dfference being I escaped the "-".

^[A-Za-z0-9. \-_]*$

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

7 REPLIES 7

Elijah Aromola
Mega Sage

This is the exact same regular expression used for platform view? can you post a screenshot?

Hi Elijah,

Thanks for the reply. This is the catalog client script written on change of the field. I attached Screen shot. Please take a look

 

 

Regards

Vijay

Hi there,

Something like below should work. Just tested on Madrid with the Question Regular Expressions. Dfference being I escaped the "-".

^[A-Za-z0-9. \-_]*$

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi there,

Is your question solved with this? Or do we need to follow-up on this?

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn