Regex Validation for UPPERCASE combination of letters and or numbers without script and with Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 07:46 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 10:37 AM - edited 10-02-2024 10:37 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 08:24 PM
@AshishKM I have just tried it, but did not work. Please should I do again please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 09:08 PM
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:
Add this regex to catalog variable
When an invalid input is entered, an error message is shown
"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