- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 05:13 PM
Hello Team - I am creating a Catalog Item and will add a question for requester's to provide an account number of some sort. How do I configure this to check for proper number formatting? Account number maybe something like 00-0000-0000-00 blah blah. What is the easiest, best practice option to do so please? Thank you.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2020 01:05 AM
If you don't have any experience with scripting, recommend creating a Variable Validation Regex because there's no scripting.
Since it's customer number, you'll probably use it more then 1 form?
To create and use Variable Validation Regex.
1. From Navigator, search "Regex". Select "Variable Validation Regex" and then "New" button.
2. Enter as in the following and select "Submit" to save.
3. Open your form. Open the variable "customer number". Select the "Type Specifications" tab. Select "Customer Number" as Validation Regex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 05:25 PM
You will need an onChange client script to check if there is a '-' at the right place and the characters entered between those '-' are numbers
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 05:44 PM
The easiest way is to create a "Variable Validation Regex" (Service Catalog > Catalog Variable > Variable Validataion Regex) and to specify it Validation Regex (Type Specification tab)
For example, to match "00-0000-0000-00", regular expression would be like below:
^\d{2}-\d{4}-\d{4}-\d{2}$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 05:56 PM
Another method is to create a Catalog Client Script. If the same regular expression is going to be used in several forms, it is better to create a Variable Validation Regex but if it's only to be used once, Catalog Client Script can be used.
Example:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var pattern = /^\d{2}-\d{4}-\d{4}-\d{2}$/;
if (!pattern.test(newValue)) {
g_form.showFieldMsg('field', 'Illegal value.');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 06:59 PM
Thank you Hozawa. Is there a variable that does numbers or currency only? ie, advise requesters to add a $ limit, or would the 'single line text' be the next best type to use? Cheers.
