Regex Validation for UPPERCASE combination of letters and or numbers without script and with Script.

Austine
Tera Contributor

Please I have the following requirements that I need help with.

 

1. I need some scripts for Regex Validation that only allows ALL CAPS combination of letters and or numbers in string fields. And if users do not meet the requirements and use lowercase letters or not adding numbers in the field value, they should not be allowed to submit the form.

2. Secondly, I need another way of solving the regex validation task without writing any script.

 

7 REPLIES 7

Hello @Austine 

 

Just modify the regex to ^[A-Z0-9!@#$%&*_\-\s]*$ to add the special character and white space.

Additionally, to make the alphabets and numbers mandatory the regex can be modified to ^(?=.*[A-Z])(?=.*[0-9])[A-Z0-9!@#$%&*_\-\s]*$

 

"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"

 

Thank You

Juhi Poddar

 

Austine
Tera Contributor

@AshishKM I have just tried it, but did not work. Please should I do again please?

Juhi Poddar
Kilo Patron

Hello @Austine 

 

ServiceNow provides out-of-the-box (OOTB) solutions for regex validation without requiring custom scripting.

Create a new record in Question Regular Expressions(question_regex) table with following configuration:

JuhiPoddar_0-1727841494085.png

Add this regex to catalog variable

JuhiPoddar_1-1727841611663.png

When an invalid input is entered, an error message is shown 

JuhiPoddar_2-1727841809640.png

 

"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"

 

Thank You

Juhi Poddar