- 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 07:32 PM
The above will only accept number and hyphen.
"d{2}" implies 2 digit number. Likewise, "d{4}" implies 4 digit number.
"\-" implies a hyphen.
So any other character will fail on the test.
"^" implies starts with so the value must start with 2 digit decimal. If there is a space or some other character, the test would fail.
"$" implies ends with. So if the value ends with a space or some other character, the test would also fail.
I've tested both Variable Validation Regex and Catalog Client Script using single line text.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 11:12 PM
Appreciate your help Hozawa. Forgot to mention, my scripting capabilities are zero to none 🙂 so struggling abit to read the above Example. I've only got as far as creating a new variable: Type is Single Line Text > name is: customer_number. Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2020 11:46 PM
Hi,
Try below onChange catalog client script on account no variable.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var val=g_form.getValue('account_no'); // change name of variable here
alert(val);
var pattern= /\d{2}-\d{4}-\d{4}-\d{2}/;
if(val.search(pattern)==-1)
{
alert("Incorrect account no, please enter correct one");
g_form.clearValue('account_no'); // change name of variable here
}
else{
alert("correct account no");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2020 01:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2020 01:29 AM
Hi,
I don't think there is something which will take cursor to back. You have to do that manually.
Thanks,
Dhananjay.
