Variable validation

Vaishali 11
Tera Guru

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

4 REPLIES 4

reshmapatil
Tera Guru

Hi @Vaishali 11 ,

 

1. Use URL type variable.

reshmapatil_0-1671638223643.png

 

2. Add Regex (field present in variable configuration form)

reshmapatil_1-1671638251366.png

 

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**

@reshmapatil ,

there is already a onsubmit script.

Vaishali11_0-1671694553195.png

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?

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:

https://www.servicenow.com/community/developer-articles/common-regular-expressions-and-cheat-sheet/t...

 

https://www.servicenow.com/community/developer-articles/field-validation-regular-expressions/ta-p/23...