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.

Text validation to allow alphanumeric and space

CatalogCat
Tera Contributor

I have a catalog client script that validates that input is alphanumeric:

var regex = new RegExp("^[a-zA-Z0-9]*$");
How can I include space in this?
1 ACCEPTED SOLUTION

aizawaken
Tera Guru

Hi @CatalogCat ,

 

How about just adding space as below? 

var regex = new RegExp("^[ a-zA-Z0-9]*$");

 or adding "\s" like this?

var regex = new RegExp("^[a-zA-Z0-9\s]*$");

 
Is this what you want to do?

 

View solution in original post

2 REPLIES 2

aizawaken
Tera Guru

Hi @CatalogCat ,

 

How about just adding space as below? 

var regex = new RegExp("^[ a-zA-Z0-9]*$");

 or adding "\s" like this?

var regex = new RegExp("^[a-zA-Z0-9\s]*$");

 
Is this what you want to do?

 

CatalogCat
Tera Contributor

Thanks, @aizawaken , the first one worked fine.