We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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.