Variable validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 07:29 AM
For a catalog item variable, I want to enter url and it should have the validation that the url should end with .git.
How to achieve this?
Thanks,
Vaishali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 07:48 AM - edited 12-21-2022 07:58 AM
Hi @Vaishali 11 ,
1. Use URL type variable.
2. Add Regex (field present in variable configuration form)
3. Validation through script:
https://www.servicenow.com/community/developer-forum/url-validation/m-p/2157833
Regards,
Reshma
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 11:36 PM
there is already a onsubmit script.
this is validating for https. Now for that field only i also want to validate if it is ending with .git.
Could you please tell how it can be achieved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2022 12:03 AM - edited 12-22-2022 12:10 AM
Hi @Vaishali 11 ,
1. In same onSubmit Client Script, you can add regex validation for your URL variable.
2. Or you can have a single line text type variable and add a Variable Regex field present to the variable configuration form.
3. Create a new regex in the 'Variable Validation Regex' table. Set it in a single-line text type variable.
Check this Regex: ([a-zA-Z0-9_\-\.])+(\git)
Check how to create regex:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 07:55 AM
Hello,
Check these out
Regards,
Musab