Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

sLimit special characters and spaces

Arka Banerjee
Mega Guru

Hi Team,

 

Suppose I have a single line text field on a ritm. How to limit special characters and spaces input on that so that it accepts only numbers and alphabets

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Arka Banerjee 

Is that a variable where you want validation during catalog form submission?

if yes then please use variable validation regex where no script is required

Out of the box there is already 1 for numbers and alphabets

AnkurBawiskar_0-1713536161461.png

 

Simply associate this to your variable under type specifications

 

AnkurBawiskar_1-1713536242970.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, 

 

Thanks, but this doesn't prevent spaces from being entered in the field, can you kindly help with how I can prevent spaces(at the start, in between or in the end) as well maybe by modifying the validation regex.

Hi @Arka Banerjee 

 

Can you try this-

 

/^[a-zA-Z0-9]*$/

 

Regards,

Amit

Hi Amit,

 

It says that its not a valid regular expression upon trying to save